Last active
February 15, 2016 15:23
-
-
Save shssoichiro/223c32bcca8ac8d9bf40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
extern crate test; | |
#[cfg(test)] | |
mod tests { | |
use test::Bencher; | |
#[bench] | |
fn bench_split_short_str(b: &mut Bencher) { | |
b.iter(|| { | |
let x = "asdfghjkl"; | |
x.split("f"); | |
}); | |
} | |
#[bench] | |
fn bench_split_short_char(b: &mut Bencher) { | |
b.iter(|| { | |
let x = "asdfghjkl"; | |
x.split('f'); | |
}); | |
} | |
#[bench] | |
fn bench_split_long_str_one_split(b: &mut Bencher) { | |
b.iter(|| { | |
let x = "asdfghjklqwertyuiopzxcvvbnm1234567890"; | |
x.split("f"); | |
}); | |
} | |
#[bench] | |
fn bench_split_long_char_one_split(b: &mut Bencher) { | |
b.iter(|| { | |
let x = "asdfghjklqwertyuiopzxcvvbnm1234567890"; | |
x.split('f'); | |
}); | |
} | |
#[bench] | |
fn bench_split_long_str_multi_splits(b: &mut Bencher) { | |
b.iter(|| { | |
let x = "asdfghjklqwerftyuiofpzxcvvbfnm123f4567f890"; | |
x.split("f"); | |
}); | |
} | |
#[bench] | |
fn bench_split_long_char_multi_splits(b: &mut Bencher) { | |
b.iter(|| { | |
let x = "asdfghjklqwerftyuiofpzxcvvbfnm123f4567f890"; | |
x.split('f'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment