1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
14 use test::{Bencher, black_box};
16 pub fn insert_rand_n<M, I, R>(n: uint,
21 I: FnMut(&mut M, uint),
22 R: FnMut(&mut M, uint),
25 let mut rng = rand::weak_rng();
28 insert(map, rng.gen::<uint>() % n);
33 let k = rng.gen::<uint>() % n;
40 pub fn insert_seq_n<M, I, R>(n: uint,
45 I: FnMut(&mut M, uint),
46 R: FnMut(&mut M, uint),
63 pub fn find_rand_n<M, T, I, F>(n: uint,
68 I: FnMut(&mut M, uint),
69 F: FnMut(&M, uint) -> T,
72 let mut rng = rand::weak_rng();
73 let mut keys = (0..n).map(|_| rng.gen::<uint>() % n)
80 rng.shuffle(&mut keys);
85 let t = find(map, keys[i]);
91 pub fn find_seq_n<M, T, I, F>(n: uint,
96 I: FnMut(&mut M, uint),
97 F: FnMut(&M, uint) -> T,
107 let x = find(map, i);