Skip to content

Commit 96ae60c

Browse files
committed
rename test::BenchHarness to test::Bencher
Closes #12640
1 parent a92dcb0 commit 96ae60c

38 files changed

+481
-481
lines changed

src/doc/guide-testing.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ runner.
170170

171171
The type signature of a benchmark function differs from a unit test:
172172
it takes a mutable reference to type
173-
`test::BenchHarness`. Inside the benchmark function, any
173+
`test::Bencher`. Inside the benchmark function, any
174174
time-variable or "setup" code should execute first, followed by a call
175175
to `iter` on the benchmark harness, passing a closure that contains
176176
the portion of the benchmark you wish to actually measure the
@@ -192,13 +192,13 @@ use std::slice;
192192
use test::BenchHarness;
193193
194194
#[bench]
195-
fn bench_sum_1024_ints(b: &mut BenchHarness) {
195+
fn bench_sum_1024_ints(b: &mut Bencher) {
196196
let v = slice::from_fn(1024, |n| n);
197197
b.iter(|| {v.iter().fold(0, |old, new| old + *new);} );
198198
}
199199
200200
#[bench]
201-
fn initialise_a_vector(b: &mut BenchHarness) {
201+
fn initialise_a_vector(b: &mut Bencher) {
202202
b.iter(|| {slice::from_elem(1024, 0u64);} );
203203
b.bytes = 1024 * 8;
204204
}
@@ -249,11 +249,11 @@ it entirely.
249249
~~~
250250
# #[allow(unused_imports)];
251251
extern crate test;
252-
use test::BenchHarness;
252+
use test::Bencher;
253253
254254
#[bench]
255-
fn bench_xor_1000_ints(bh: &mut BenchHarness) {
256-
bh.iter(|| {
255+
fn bench_xor_1000_ints(b: &mut Bencher) {
256+
b.iter(|| {
257257
range(0, 1000).fold(0, |old, new| old ^ new);
258258
});
259259
}

src/libarena/lib.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl<T> Drop for TypedArena<T> {
489489
#[cfg(test)]
490490
mod tests {
491491
extern crate test;
492-
use self::test::BenchHarness;
492+
use self::test::Bencher;
493493
use super::{Arena, TypedArena};
494494

495495
struct Point {
@@ -511,9 +511,9 @@ mod tests {
511511
}
512512

513513
#[bench]
514-
pub fn bench_pod(bh: &mut BenchHarness) {
514+
pub fn bench_pod(b: &mut Bencher) {
515515
let arena = TypedArena::new();
516-
bh.iter(|| {
516+
b.iter(|| {
517517
arena.alloc(Point {
518518
x: 1,
519519
y: 2,
@@ -523,8 +523,8 @@ mod tests {
523523
}
524524

525525
#[bench]
526-
pub fn bench_pod_nonarena(bh: &mut BenchHarness) {
527-
bh.iter(|| {
526+
pub fn bench_pod_nonarena(b: &mut Bencher) {
527+
b.iter(|| {
528528
~Point {
529529
x: 1,
530530
y: 2,
@@ -534,9 +534,9 @@ mod tests {
534534
}
535535

536536
#[bench]
537-
pub fn bench_pod_old_arena(bh: &mut BenchHarness) {
537+
pub fn bench_pod_old_arena(b: &mut Bencher) {
538538
let arena = Arena::new();
539-
bh.iter(|| {
539+
b.iter(|| {
540540
arena.alloc(|| {
541541
Point {
542542
x: 1,
@@ -564,9 +564,9 @@ mod tests {
564564
}
565565

566566
#[bench]
567-
pub fn bench_nonpod(bh: &mut BenchHarness) {
567+
pub fn bench_nonpod(b: &mut Bencher) {
568568
let arena = TypedArena::new();
569-
bh.iter(|| {
569+
b.iter(|| {
570570
arena.alloc(Nonpod {
571571
string: ~"hello world",
572572
array: ~[ 1, 2, 3, 4, 5 ],
@@ -575,8 +575,8 @@ mod tests {
575575
}
576576

577577
#[bench]
578-
pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) {
579-
bh.iter(|| {
578+
pub fn bench_nonpod_nonarena(b: &mut Bencher) {
579+
b.iter(|| {
580580
~Nonpod {
581581
string: ~"hello world",
582582
array: ~[ 1, 2, 3, 4, 5 ],
@@ -585,9 +585,9 @@ mod tests {
585585
}
586586

587587
#[bench]
588-
pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) {
588+
pub fn bench_nonpod_old_arena(b: &mut Bencher) {
589589
let arena = Arena::new();
590-
bh.iter(|| {
590+
b.iter(|| {
591591
arena.alloc(|| Nonpod {
592592
string: ~"hello world",
593593
array: ~[ 1, 2, 3, 4, 5 ],

src/libcollections/bitv.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ impl<'a> Iterator<uint> for BitPositions<'a> {
939939
#[cfg(test)]
940940
mod tests {
941941
extern crate test;
942-
use self::test::BenchHarness;
942+
use self::test::Bencher;
943943

944944
use bitv::{Bitv, SmallBitv, BigBitv, BitvSet, from_bools, from_fn,
945945
from_bytes};
@@ -1557,7 +1557,7 @@ mod tests {
15571557
}
15581558

15591559
#[bench]
1560-
fn bench_uint_small(b: &mut BenchHarness) {
1560+
fn bench_uint_small(b: &mut Bencher) {
15611561
let mut r = rng();
15621562
let mut bitv = 0 as uint;
15631563
b.iter(|| {
@@ -1567,7 +1567,7 @@ mod tests {
15671567
}
15681568

15691569
#[bench]
1570-
fn bench_small_bitv_small(b: &mut BenchHarness) {
1570+
fn bench_small_bitv_small(b: &mut Bencher) {
15711571
let mut r = rng();
15721572
let mut bitv = SmallBitv::new(uint::BITS);
15731573
b.iter(|| {
@@ -1577,7 +1577,7 @@ mod tests {
15771577
}
15781578

15791579
#[bench]
1580-
fn bench_big_bitv_small(b: &mut BenchHarness) {
1580+
fn bench_big_bitv_small(b: &mut Bencher) {
15811581
let mut r = rng();
15821582
let mut bitv = BigBitv::new(~[0]);
15831583
b.iter(|| {
@@ -1587,7 +1587,7 @@ mod tests {
15871587
}
15881588

15891589
#[bench]
1590-
fn bench_big_bitv_big(b: &mut BenchHarness) {
1590+
fn bench_big_bitv_big(b: &mut Bencher) {
15911591
let mut r = rng();
15921592
let mut storage = ~[];
15931593
storage.grow(BENCH_BITS / uint::BITS, &0u);
@@ -1599,7 +1599,7 @@ mod tests {
15991599
}
16001600

16011601
#[bench]
1602-
fn bench_bitv_big(b: &mut BenchHarness) {
1602+
fn bench_bitv_big(b: &mut Bencher) {
16031603
let mut r = rng();
16041604
let mut bitv = Bitv::new(BENCH_BITS, false);
16051605
b.iter(|| {
@@ -1609,7 +1609,7 @@ mod tests {
16091609
}
16101610

16111611
#[bench]
1612-
fn bench_bitv_small(b: &mut BenchHarness) {
1612+
fn bench_bitv_small(b: &mut Bencher) {
16131613
let mut r = rng();
16141614
let mut bitv = Bitv::new(uint::BITS, false);
16151615
b.iter(|| {
@@ -1619,7 +1619,7 @@ mod tests {
16191619
}
16201620

16211621
#[bench]
1622-
fn bench_bitv_set_small(b: &mut BenchHarness) {
1622+
fn bench_bitv_set_small(b: &mut Bencher) {
16231623
let mut r = rng();
16241624
let mut bitv = BitvSet::new();
16251625
b.iter(|| {
@@ -1629,7 +1629,7 @@ mod tests {
16291629
}
16301630

16311631
#[bench]
1632-
fn bench_bitv_set_big(b: &mut BenchHarness) {
1632+
fn bench_bitv_set_big(b: &mut Bencher) {
16331633
let mut r = rng();
16341634
let mut bitv = BitvSet::new();
16351635
b.iter(|| {
@@ -1639,7 +1639,7 @@ mod tests {
16391639
}
16401640

16411641
#[bench]
1642-
fn bench_bitv_big_union(b: &mut BenchHarness) {
1642+
fn bench_bitv_big_union(b: &mut Bencher) {
16431643
let mut b1 = Bitv::new(BENCH_BITS, false);
16441644
let b2 = Bitv::new(BENCH_BITS, false);
16451645
b.iter(|| {
@@ -1648,7 +1648,7 @@ mod tests {
16481648
}
16491649

16501650
#[bench]
1651-
fn bench_btv_small_iter(b: &mut BenchHarness) {
1651+
fn bench_btv_small_iter(b: &mut Bencher) {
16521652
let bitv = Bitv::new(uint::BITS, false);
16531653
b.iter(|| {
16541654
let mut _sum = 0;
@@ -1659,7 +1659,7 @@ mod tests {
16591659
}
16601660

16611661
#[bench]
1662-
fn bench_bitv_big_iter(b: &mut BenchHarness) {
1662+
fn bench_bitv_big_iter(b: &mut Bencher) {
16631663
let bitv = Bitv::new(BENCH_BITS, false);
16641664
b.iter(|| {
16651665
let mut _sum = 0;
@@ -1670,7 +1670,7 @@ mod tests {
16701670
}
16711671

16721672
#[bench]
1673-
fn bench_bitvset_iter(b: &mut BenchHarness) {
1673+
fn bench_bitvset_iter(b: &mut Bencher) {
16741674
let bitv = BitvSet::from_bitv(from_fn(BENCH_BITS,
16751675
|idx| {idx % 3 == 0}));
16761676
b.iter(|| {

src/libcollections/deque.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ pub trait Deque<T> : Mutable {
4242
#[cfg(test)]
4343
pub mod bench {
4444
extern crate test;
45-
use self::test::BenchHarness;
45+
use self::test::Bencher;
4646
use std::container::MutableMap;
4747
use std::slice;
4848
use rand;
4949
use rand::Rng;
5050

5151
pub fn insert_rand_n<M:MutableMap<uint,uint>>(n: uint,
5252
map: &mut M,
53-
bh: &mut BenchHarness) {
53+
b: &mut Bencher) {
5454
// setup
5555
let mut rng = rand::XorShiftRng::new();
5656

@@ -60,7 +60,7 @@ pub mod bench {
6060
}
6161

6262
// measure
63-
bh.iter(|| {
63+
b.iter(|| {
6464
let k = rng.gen::<uint>() % n;
6565
map.insert(k, 1);
6666
map.remove(&k);
@@ -69,7 +69,7 @@ pub mod bench {
6969

7070
pub fn insert_seq_n<M:MutableMap<uint,uint>>(n: uint,
7171
map: &mut M,
72-
bh: &mut BenchHarness) {
72+
b: &mut Bencher) {
7373
// setup
7474
map.clear();
7575
for i in range(0u, n) {
@@ -78,7 +78,7 @@ pub mod bench {
7878

7979
// measure
8080
let mut i = 1;
81-
bh.iter(|| {
81+
b.iter(|| {
8282
map.insert(i, 1);
8383
map.remove(&i);
8484
i = (i + 2) % n;
@@ -87,7 +87,7 @@ pub mod bench {
8787

8888
pub fn find_rand_n<M:MutableMap<uint,uint>>(n: uint,
8989
map: &mut M,
90-
bh: &mut BenchHarness) {
90+
b: &mut Bencher) {
9191
// setup
9292
let mut rng = rand::XorShiftRng::new();
9393
let mut keys = slice::from_fn(n, |_| rng.gen::<uint>() % n);
@@ -100,23 +100,23 @@ pub mod bench {
100100

101101
// measure
102102
let mut i = 0;
103-
bh.iter(|| {
103+
b.iter(|| {
104104
map.find(&(keys[i]));
105105
i = (i + 1) % n;
106106
})
107107
}
108108

109109
pub fn find_seq_n<M:MutableMap<uint,uint>>(n: uint,
110110
map: &mut M,
111-
bh: &mut BenchHarness) {
111+
b: &mut Bencher) {
112112
// setup
113113
for i in range(0u, n) {
114114
map.insert(i, 1);
115115
}
116116

117117
// measure
118118
let mut i = 0;
119-
bh.iter(|| {
119+
b.iter(|| {
120120
let x = map.find(&i);
121121
i = (i + 1) % n;
122122
x

0 commit comments

Comments
 (0)