Skip to content

Commit

Permalink
Merge pull request #9 from llogiq/bencher
Browse files Browse the repository at this point in the history
convert benchmarks to bluss' bencher
  • Loading branch information
llogiq authored Dec 2, 2016
2 parents 7a2d8e8 + cf89bf9 commit 447b5bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ version = "0.1.4"
license = "Apache-2.0/MIT"
repository = "https://github.com/llogiq/bytecount"

[lib]
bench = false

[features]
avx-accel = ["simd-accel"]
simd-accel = ["simd"]
Expand All @@ -16,3 +19,8 @@ simd = { version = "0.1.1", optional = true }
[dev-dependencies]
quickcheck = "0.3.1"
rand = "0.3.14"
bencher = "0.1"

[[bench]]
name = "bench"
harness = false
21 changes: 15 additions & 6 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(test)]

extern crate test;
#[macro_use]
extern crate bencher;
extern crate rand;
extern crate bytecount;

Expand All @@ -14,14 +14,12 @@ fn random_bytes(len: usize) -> Vec<u8> {

macro_rules! bench {
($i: expr, $name_naive: ident, $name_hyper: ident) => {
#[bench]
fn $name_naive(b: &mut test::Bencher) {
fn $name_naive(b: &mut bencher::Bencher) {
let haystack = random_bytes($i);
b.iter(|| naive_count(&haystack, 10));
}

#[bench]
fn $name_hyper(b: &mut test::Bencher) {
fn $name_hyper(b: &mut bencher::Bencher) {
let haystack = random_bytes($i);
b.iter(|| count(&haystack, 10));
}
Expand All @@ -36,3 +34,14 @@ bench!(1000, bench_1000_naive, bench_1000_hyper);
bench!(10000, bench_10000_naive, bench_10000_hyper);
bench!(100000, bench_100000_naive, bench_100000_hyper);
bench!(1000000, bench_1000000_naive, bench_1000000_hyper);

benchmark_group!(bench, bench_0_naive, bench_0_hyper,
bench_1_naive, bench_1_hyper,
bench_10_naive, bench_10_hyper,
bench_100_naive, bench_100_hyper,
bench_1000_naive, bench_1000_hyper,
bench_10000_naive, bench_10000_hyper,
bench_100000_naive, bench_100000_hyper,
bench_1000000_naive, bench_1000000_hyper);

benchmark_main!(bench);
1 change: 1 addition & 0 deletions src/bench.rs

0 comments on commit 447b5bb

Please sign in to comment.