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.
11 macro_rules! map_insert_rand_bench {
12 ($name: ident, $n: expr, $map: ident) => (
14 pub fn $name(b: &mut ::test::Bencher) {
20 let mut map = $map::new();
22 let mut rng = rand::weak_rng();
25 let i = rng.gen::<usize>() % n;
31 let k = rng.gen::<usize>() % n;
40 macro_rules! map_insert_seq_bench {
41 ($name: ident, $n: expr, $map: ident) => (
43 pub fn $name(b: &mut ::test::Bencher) {
46 let mut map = $map::new();
50 map.insert(i * 2, i * 2);
65 macro_rules! map_find_rand_bench {
66 ($name: ident, $n: expr, $map: ident) => (
68 pub fn $name(b: &mut ::test::Bencher) {
69 use std::iter::Iterator;
75 let mut map = $map::new();
79 let mut rng = rand::weak_rng();
80 let mut keys: Vec<_> = (0..n).map(|_| rng.gen::<usize>() % n).collect();
86 rng.shuffle(&mut keys);
91 let t = map.get(&keys[i]);
99 macro_rules! map_find_seq_bench {
100 ($name: ident, $n: expr, $map: ident) => (
102 pub fn $name(b: &mut ::test::Bencher) {
105 let mut map = $map::new();