Skip to content

Commit a9ea4d0

Browse files
author
Jorge Aparicio
committed
fix benchmarks
1 parent ef72659 commit a9ea4d0

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/test/bench/core-set.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ impl MutableSet<uint> for BitvSet {
6161

6262
impl Results {
6363
pub fn bench_int<T:MutableSet<uint>,
64-
R: rand::Rng>(
64+
R:rand::Rng,
65+
F:FnMut() -> T>(
6566
&mut self,
6667
rng: &mut R,
6768
num_keys: uint,
6869
rand_cap: uint,
69-
f: || -> T) { {
70+
mut f: F) {
71+
{
7072
let mut set = f();
7173
timed(&mut self.sequential_ints, || {
7274
for i in range(0u, num_keys) {
@@ -103,11 +105,12 @@ impl Results {
103105
}
104106

105107
pub fn bench_str<T:MutableSet<String>,
106-
R:rand::Rng>(
108+
R:rand::Rng,
109+
F:FnMut() -> T>(
107110
&mut self,
108111
rng: &mut R,
109112
num_keys: uint,
110-
f: || -> T) {
113+
mut f: F) {
111114
{
112115
let mut set = f();
113116
timed(&mut self.sequential_strings, || {

src/test/bench/shootout-k-nucleotide-pipes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
9494
// given a Vec<u8>, for each window call a function
9595
// i.e., for "hello" and windows of size four,
9696
// run it("hell") and it("ello"), then return "llo"
97-
fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> {
97+
fn windows_with_carry<F>(bb: &[u8], nn: uint, mut it: F) -> Vec<u8> where
98+
F: FnMut(&[u8]),
99+
{
98100
let mut ii = 0u;
99101

100102
let len = bb.len();

src/test/bench/shootout-meteor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ use std::thread::Thread;
5353

5454
// returns an infinite iterator of repeated applications of f to x,
5555
// i.e. [x, f(x), f(f(x)), ...], as haskell iterate function.
56-
fn iterate<'a, T>(x: T, f: |&T|: 'a -> T) -> Iterate<'a, T> {
56+
fn iterate<T, F>(x: T, f: F) -> Iterate<T, F> where F: FnMut(&T) -> T {
5757
Iterate {f: f, next: x}
5858
}
59-
struct Iterate<'a, T> {
60-
f: |&T|: 'a -> T,
59+
struct Iterate<T, F> where F: FnMut(&T) -> T {
60+
f: F,
6161
next: T
6262
}
63-
impl<'a, T> Iterator for Iterate<'a, T> {
63+
impl<T, F> Iterator for Iterate<T, F> where F: FnMut(&T) -> T {
6464
type Item = T;
6565

6666
fn next(&mut self) -> Option<T> {

0 commit comments

Comments
 (0)