Skip to content

Commit b29d313

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 163795 b: refs/heads/master c: 879ebce h: refs/heads/master i: 163793: 42a47ce 163791: bcb3815 v: v3
1 parent de90f72 commit b29d313

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9b075bcf3ffef3f11d8401b55feaa02c1e6553d2
2+
refs/heads/master: 879ebce6a4023632cfd448749997ce3e4e24b05d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8443b09e361b96d1f9b7f45a65ed0d31c0e86e70
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42

trunk/src/libcollections/bench.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ use std::rand;
1313
use std::rand::Rng;
1414
use test::Bencher;
1515

16-
pub fn insert_rand_n<M>(n: uint, map: &mut M, b: &mut Bencher,
17-
insert: |&mut M, uint|,
18-
remove: |&mut M, uint|) {
16+
pub fn insert_rand_n<M, I, R>(n: uint,
17+
map: &mut M,
18+
b: &mut Bencher,
19+
mut insert: I,
20+
mut remove: R) where
21+
I: FnMut(&mut M, uint),
22+
R: FnMut(&mut M, uint),
23+
{
1924
// setup
2025
let mut rng = rand::weak_rng();
2126

@@ -31,9 +36,14 @@ pub fn insert_rand_n<M>(n: uint, map: &mut M, b: &mut Bencher,
3136
})
3237
}
3338

34-
pub fn insert_seq_n<M>(n: uint, map: &mut M, b: &mut Bencher,
35-
insert: |&mut M, uint|,
36-
remove: |&mut M, uint|) {
39+
pub fn insert_seq_n<M, I, R>(n: uint,
40+
map: &mut M,
41+
b: &mut Bencher,
42+
mut insert: I,
43+
mut remove: R) where
44+
I: FnMut(&mut M, uint),
45+
R: FnMut(&mut M, uint),
46+
{
3747
// setup
3848
for i in range(0u, n) {
3949
insert(map, i * 2);
@@ -48,9 +58,14 @@ pub fn insert_seq_n<M>(n: uint, map: &mut M, b: &mut Bencher,
4858
})
4959
}
5060

51-
pub fn find_rand_n<M, T>(n: uint, map: &mut M, b: &mut Bencher,
52-
insert: |&mut M, uint|,
53-
find: |&M, uint| -> T) {
61+
pub fn find_rand_n<M, T, I, F>(n: uint,
62+
map: &mut M,
63+
b: &mut Bencher,
64+
mut insert: I,
65+
mut find: F) where
66+
I: FnMut(&mut M, uint),
67+
F: FnMut(&M, uint) -> T,
68+
{
5469
// setup
5570
let mut rng = rand::weak_rng();
5671
let mut keys = Vec::from_fn(n, |_| rng.gen::<uint>() % n);
@@ -70,9 +85,14 @@ pub fn find_rand_n<M, T>(n: uint, map: &mut M, b: &mut Bencher,
7085
})
7186
}
7287

73-
pub fn find_seq_n<M, T>(n: uint, map: &mut M, b: &mut Bencher,
74-
insert: |&mut M, uint|,
75-
find: |&M, uint| -> T) {
88+
pub fn find_seq_n<M, T, I, F>(n: uint,
89+
map: &mut M,
90+
b: &mut Bencher,
91+
mut insert: I,
92+
mut find: F) where
93+
I: FnMut(&mut M, uint),
94+
F: FnMut(&M, uint) -> T,
95+
{
7696
// setup
7797
for i in range(0u, n) {
7898
insert(map, i);

0 commit comments

Comments
 (0)