Skip to content

Commit da5e8ce

Browse files
committed
bitv: make sure benchmarks run long enough
Previously they were too short (less than 10 ns), so the benchmarker could not resolve them meaningfully. Now they should run in the order of 100 ns.
1 parent 4d41a42 commit da5e8ce

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/libcollections/bitv.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,9 @@ mod tests {
25662566
let mut r = rng();
25672567
let mut bitv = 0 as uint;
25682568
b.iter(|| {
2569-
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
2569+
for _ in range(0u, 100) {
2570+
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
2571+
}
25702572
&bitv
25712573
})
25722574
}
@@ -2576,7 +2578,9 @@ mod tests {
25762578
let mut r = rng();
25772579
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25782580
b.iter(|| {
2579-
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
2581+
for _ in range(0u, 100) {
2582+
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
2583+
}
25802584
&bitv
25812585
})
25822586
}
@@ -2586,7 +2590,9 @@ mod tests {
25862590
let mut r = rng();
25872591
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25882592
b.iter(|| {
2589-
bitv.set((r.next_u32() as uint) % uint::BITS, true);
2593+
for _ in range(0u, 100) {
2594+
bitv.set((r.next_u32() as uint) % uint::BITS, true);
2595+
}
25902596
&bitv
25912597
})
25922598
}
@@ -2596,7 +2602,9 @@ mod tests {
25962602
let mut r = rng();
25972603
let mut bitv = BitvSet::new();
25982604
b.iter(|| {
2599-
bitv.insert((r.next_u32() as uint) % uint::BITS);
2605+
for _ in range(0u, 100) {
2606+
bitv.insert((r.next_u32() as uint) % uint::BITS);
2607+
}
26002608
&bitv
26012609
})
26022610
}
@@ -2606,7 +2614,9 @@ mod tests {
26062614
let mut r = rng();
26072615
let mut bitv = BitvSet::new();
26082616
b.iter(|| {
2609-
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
2617+
for _ in range(0u, 100) {
2618+
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
2619+
}
26102620
&bitv
26112621
})
26122622
}
@@ -2625,8 +2635,10 @@ mod tests {
26252635
let bitv = Bitv::with_capacity(uint::BITS, false);
26262636
b.iter(|| {
26272637
let mut sum = 0;
2628-
for pres in bitv.iter() {
2629-
sum += pres as uint;
2638+
for _ in range(0u, 10) {
2639+
for pres in bitv.iter() {
2640+
sum += pres as uint;
2641+
}
26302642
}
26312643
sum
26322644
})

0 commit comments

Comments
 (0)