diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-01-31 19:07:08 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-01-31 23:22:51 -0500 |
| commit | 74b317ddc24fb0b5ffcbaafb0983cc5ddfd4a714 (patch) | |
| tree | 3da6136f5526c3c45e6a3e0a65f8a14d4c238b53 /src/test/bench/std-smallintmap.rs | |
| parent | 348d770fedcddad7d814bd41072efc0602c739c8 (diff) | |
| download | rust-74b317ddc24fb0b5ffcbaafb0983cc5ddfd4a714.tar.gz rust-74b317ddc24fb0b5ffcbaafb0983cc5ddfd4a714.zip | |
modernize smallintmap
* switch to explicit self * get rid of the @ box * replace DVec with ~[] (to get rid of the mutable field) * implement the new container::Map trait
Diffstat (limited to 'src/test/bench/std-smallintmap.rs')
| -rw-r--r-- | src/test/bench/std-smallintmap.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 60efb14e2dc..0687799cf28 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -8,22 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Microbenchmark for the oldsmallintmap library +// Microbenchmark for the smallintmap library extern mod std; -use std::oldsmallintmap; -use std::oldsmallintmap::SmallIntMap; +use std::smallintmap::SmallIntMap; use io::WriterUtil; -fn append_sequential(min: uint, max: uint, map: SmallIntMap<uint>) { +fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) { for uint::range(min, max) |i| { map.insert(i, i + 22u); } } -fn check_sequential(min: uint, max: uint, map: SmallIntMap<uint>) { +fn check_sequential(min: uint, max: uint, map: &SmallIntMap<uint>) { for uint::range(min, max) |i| { - assert map.get(i) == i + 22u; + assert *map.get(&i) == i + 22u; } } @@ -43,11 +42,11 @@ fn main() { let mut appendf = 0.0; for uint::range(0u, rep) |_r| { - let map = oldsmallintmap::mk(); + let mut map = SmallIntMap::new(); let start = std::time::precise_time_s(); - append_sequential(0u, max, map); + append_sequential(0u, max, &mut map); let mid = std::time::precise_time_s(); - check_sequential(0u, max, map); + check_sequential(0u, max, &map); let end = std::time::precise_time_s(); checkf += (end - mid) as float; |
