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) {
15 use std::__rand::{thread_rng, Rng};
19 let mut map = $map::new();
21 let mut rng = thread_rng();
24 let i = rng.gen::<usize>() % n;
30 let k = rng.gen::<usize>() % n;
39 macro_rules! map_insert_seq_bench {
40 ($name: ident, $n: expr, $map: ident) => (
42 pub fn $name(b: &mut ::test::Bencher) {
45 let mut map = $map::new();
49 map.insert(i * 2, i * 2);
64 macro_rules! map_find_rand_bench {
65 ($name: ident, $n: expr, $map: ident) => (
67 pub fn $name(b: &mut ::test::Bencher) {
68 use std::iter::Iterator;
69 use std::__rand::{thread_rng, Rng};
73 let mut map = $map::new();
77 let mut rng = thread_rng();
78 let mut keys: Vec<_> = (0..n).map(|_| rng.gen::<usize>() % n).collect();
84 rng.shuffle(&mut keys);
89 let t = map.get(&keys[i]);
97 macro_rules! map_find_seq_bench {
98 ($name: ident, $n: expr, $map: ident) => (
100 pub fn $name(b: &mut ::test::Bencher) {
103 let mut map = $map::new();