diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-08 21:32:09 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-09 12:31:45 +1100 |
| commit | 38447344f1f1dc3c3bb0cbcf361deee49e2f9828 (patch) | |
| tree | 3c219adb296d63dacaa7b4999bab6bdd309a00c7 | |
| parent | b029a188205b704fed28d4fbe0037a453ace0ea1 (diff) | |
| download | rust-38447344f1f1dc3c3bb0cbcf361deee49e2f9828.tar.gz rust-38447344f1f1dc3c3bb0cbcf361deee49e2f9828.zip | |
arena: use the generic `bh.iter` to stop the benchmarks being DCE'd.
Before:
test test::bench_nonpod_nonarena ... bench: 62 ns/iter (+/- 6)
test test::bench_pod_nonarena ... bench: 0 ns/iter (+/- 0)
After:
test test::bench_nonpod_nonarena ... bench: 158 ns/iter (+/- 11)
test test::bench_pod_nonarena ... bench: 48 ns/iter (+/- 2)
The other tests show no change, but are adjusted to use the generic
return value of `.iter` anyway so that this doesn't change in future.
| -rw-r--r-- | src/libarena/lib.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 856540989df..3e3ecdda3b0 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -536,18 +536,18 @@ mod test { x: 1, y: 2, z: 3, - }); + }) }) } #[bench] pub fn bench_pod_nonarena(bh: &mut BenchHarness) { bh.iter(|| { - let _ = ~Point { + ~Point { x: 1, y: 2, z: 3, - }; + } }) } @@ -561,7 +561,7 @@ mod test { y: 2, z: 3, } - }); + }) }) } @@ -588,17 +588,17 @@ mod test { arena.alloc(Nonpod { string: ~"hello world", array: ~[ 1, 2, 3, 4, 5 ], - }); + }) }) } #[bench] pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) { bh.iter(|| { - let _ = ~Nonpod { + ~Nonpod { string: ~"hello world", array: ~[ 1, 2, 3, 4, 5 ], - }; + } }) } @@ -606,10 +606,10 @@ mod test { pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) { let arena = Arena::new(); bh.iter(|| { - let _ = arena.alloc(|| Nonpod { + arena.alloc(|| Nonpod { string: ~"hello world", array: ~[ 1, 2, 3, 4, 5 ], - }); + }) }) } } |
