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.
This commit is contained in:
parent
4d41a4227c
commit
da5e8cef59
|
@ -2566,7 +2566,9 @@ mod tests {
|
|||
let mut r = rng();
|
||||
let mut bitv = 0 as uint;
|
||||
b.iter(|| {
|
||||
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
|
||||
for _ in range(0u, 100) {
|
||||
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
|
||||
}
|
||||
&bitv
|
||||
})
|
||||
}
|
||||
|
@ -2576,7 +2578,9 @@ mod tests {
|
|||
let mut r = rng();
|
||||
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
|
||||
b.iter(|| {
|
||||
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
|
||||
for _ in range(0u, 100) {
|
||||
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
|
||||
}
|
||||
&bitv
|
||||
})
|
||||
}
|
||||
|
@ -2586,7 +2590,9 @@ mod tests {
|
|||
let mut r = rng();
|
||||
let mut bitv = Bitv::with_capacity(uint::BITS, false);
|
||||
b.iter(|| {
|
||||
bitv.set((r.next_u32() as uint) % uint::BITS, true);
|
||||
for _ in range(0u, 100) {
|
||||
bitv.set((r.next_u32() as uint) % uint::BITS, true);
|
||||
}
|
||||
&bitv
|
||||
})
|
||||
}
|
||||
|
@ -2596,7 +2602,9 @@ mod tests {
|
|||
let mut r = rng();
|
||||
let mut bitv = BitvSet::new();
|
||||
b.iter(|| {
|
||||
bitv.insert((r.next_u32() as uint) % uint::BITS);
|
||||
for _ in range(0u, 100) {
|
||||
bitv.insert((r.next_u32() as uint) % uint::BITS);
|
||||
}
|
||||
&bitv
|
||||
})
|
||||
}
|
||||
|
@ -2606,7 +2614,9 @@ mod tests {
|
|||
let mut r = rng();
|
||||
let mut bitv = BitvSet::new();
|
||||
b.iter(|| {
|
||||
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
|
||||
for _ in range(0u, 100) {
|
||||
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
|
||||
}
|
||||
&bitv
|
||||
})
|
||||
}
|
||||
|
@ -2625,8 +2635,10 @@ mod tests {
|
|||
let bitv = Bitv::with_capacity(uint::BITS, false);
|
||||
b.iter(|| {
|
||||
let mut sum = 0;
|
||||
for pres in bitv.iter() {
|
||||
sum += pres as uint;
|
||||
for _ in range(0u, 10) {
|
||||
for pres in bitv.iter() {
|
||||
sum += pres as uint;
|
||||
}
|
||||
}
|
||||
sum
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue