Skip to content

Commit

Permalink
Merge #31
Browse files Browse the repository at this point in the history
31: Set up benchmarking system r=crepererum a=crepererum

See #9 
For now limited to a singe benchmark, but it's something. Also hooks up travis to at least compile+execute them.

Co-authored-by: Marco Neumann <[email protected]>
  • Loading branch information
bors[bot] and crepererum committed Aug 25, 2018
2 parents e37182b + 80a2087 commit 931e7ce
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 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);
4 changes: 2 additions & 2 deletions src/topk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ where
/// } else {
/// x
/// };
/// tk.add(x);
/// tk.add(y);
/// }
///
/// // later
/// let elements: Vec<u64> = tk.iter().collect();
/// assert_eq!(elements, vec![0, 1]);
/// assert_eq!(elements, vec![1, 0]);
/// ```
///
/// # Applications
Expand Down

0 comments on commit 931e7ce

Please sign in to comment.