Skip to content

Instantly share code, notes, and snippets.

@shssoichiro shssoichiro/lib.rs
Last active Feb 15, 2016

Embed
What would you like to do?
#![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
You can’t perform that action at this time.