forked from mhallin/murmurhash3-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Richard Zak <richard.j.zak@gmail.com>
- Loading branch information
Showing
4 changed files
with
53 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
use rand::RngCore; | ||
use std::iter::FromIterator; | ||
|
||
use murmurhash3::{murmurhash3_x64_128, murmurhash3_x86_32}; | ||
|
||
fn run_bench(c: &mut Criterion, size: u64) { | ||
c.bench_function("murmurhash 256k", |b| { | ||
let mut data: Vec<u8> = FromIterator::from_iter((0..size).map(|_| 0u8)); | ||
rand::thread_rng().fill_bytes(&mut data); | ||
|
||
b.iter(|| { | ||
black_box(murmurhash3_x86_32(&data, 0)); | ||
}); | ||
}); | ||
} | ||
|
||
fn run_bench128(c: &mut Criterion, size: u64) { | ||
c.bench_function("murmurhash128 256k", |b| { | ||
let mut data: Vec<u8> = FromIterator::from_iter((0..size).map(|_| 0u8)); | ||
rand::thread_rng().fill_bytes(&mut data); | ||
|
||
b.iter(|| { | ||
black_box(murmurhash3_x64_128(&data, 0)); | ||
}); | ||
}); | ||
} | ||
|
||
fn bench_random_256k(c: &mut Criterion) { | ||
run_bench(c, 256 * 1024); | ||
} | ||
|
||
fn bench_random_16b(c: &mut Criterion) { | ||
run_bench(c, 16); | ||
} | ||
|
||
fn bench_random128_256k(c: &mut Criterion) { | ||
run_bench128(c, 256 * 1024); | ||
} | ||
|
||
fn bench_random128_16b(c: &mut Criterion) { | ||
run_bench128(c, 16); | ||
} | ||
|
||
criterion_group!(benches, bench_random_16b, bench_random_256k); | ||
criterion_group!(benches128, bench_random128_16b, bench_random128_256k); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters