Skip to content

Instantly share code, notes, and snippets.

@shssoichiro
Last active February 15, 2016 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shssoichiro/223c32bcca8ac8d9bf40 to your computer and use it in GitHub Desktop.
Save shssoichiro/223c32bcca8ac8d9bf40 to your computer and use it in GitHub Desktop.
#![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