Skip to content

Commit

Permalink
global: setup benchmarking system
Browse files Browse the repository at this point in the history
  • Loading branch information
crepererum committed Aug 25, 2018
1 parent eecc2d2 commit 80a2087
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ script:
- cargo build --verbose --all
- cargo test --verbose --all
- cargo doc --verbose --all
- cargo bench --verbose --all
branches:
only:
# This is where pull requests from "bors r+" are built.
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ bytecount = "0.3"
fixedbitset = "^0.1.9"
num-traits = "^0.2.4"
rand = "0.5"

[dev-dependencies]
criterion = "0.2"

[[bench]]
name = "bloomfilter"
harness = false
22 changes: 22 additions & 0 deletions benches/bloomfilter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#[macro_use]
extern crate criterion;
extern crate pdatastructs;

use criterion::Criterion;
use pdatastructs::bloomfilter::BloomFilter;

fn bloomfilter_add_single(c: &mut Criterion) {
c.bench_function("bloomfilter_add_single", |b| {
let false_positive_rate = 0.02; // = 2%
let expected_elements = 1000;
let mut filter = BloomFilter::with_properties(expected_elements, false_positive_rate);
let obj = "foo bar";

b.iter(|| {
filter.add(&obj);
})
});
}

criterion_group!(benches, bloomfilter_add_single);
criterion_main!(benches);

0 comments on commit 80a2087

Please sign in to comment.