forked from mcountryman/simd-adler32
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Rename compete -> alts - Merge impl into -> variants - Re-group benchmarks to provide better comparision in generated criterion reports - Remove zeros,ones data as the differences between them and random were almost zero
- Loading branch information
1 parent
0b8d6d9
commit f7ab310
Showing
12 changed files
with
271 additions
and
436 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,60 @@ | ||
use criterion::{ | ||
black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, | ||
Criterion, Throughput, | ||
}; | ||
use rand::{thread_rng, RngCore}; | ||
|
||
pub fn bench(c: &mut Criterion) { | ||
let mut data = vec![0; 100_000]; | ||
let mut group = c.benchmark_group("alts"); | ||
|
||
thread_rng().fill_bytes(&mut data[..]); | ||
|
||
bench_alt(&mut group, "adler", &data, |data| { | ||
let mut adler = adler::Adler32::new(); | ||
|
||
adler.write_slice(data); | ||
adler.checksum() | ||
}); | ||
|
||
bench_alt(&mut group, "adler32", &data, |data| { | ||
let mut adler = adler32::RollingAdler32::new(); | ||
|
||
adler.update_buffer(data); | ||
adler.hash() | ||
}); | ||
|
||
bench_alt(&mut group, "simd-adler32", &data, |data| { | ||
let mut adler = simd_adler32::Adler32::new(); | ||
|
||
adler.write(data); | ||
adler.finish() | ||
}); | ||
} | ||
|
||
fn bench_alt<M, F>(g: &mut BenchmarkGroup<M>, name: &str, data: &[u8], mut imp: F) | ||
where | ||
M: Measurement, | ||
F: FnMut(&[u8]) -> u32, | ||
{ | ||
g.throughput(Throughput::Bytes(10)).bench_with_input( | ||
format!("{}-10b", name), | ||
&data[..10], | ||
|b, data| b.iter(|| black_box(imp(data))), | ||
); | ||
|
||
g.throughput(Throughput::Bytes(10_000)).bench_with_input( | ||
format!("{}-10k", name), | ||
&data[..10_000], | ||
|b, data| b.iter(|| black_box(imp(data))), | ||
); | ||
|
||
g.throughput(Throughput::Bytes(100_000)).bench_with_input( | ||
format!("{}-100k", name), | ||
&data[..100_000], | ||
|b, data| b.iter(|| black_box(imp(data))), | ||
); | ||
} | ||
|
||
criterion_group!(benches, bench); | ||
criterion_main!(benches); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,61 @@ | ||
use criterion::{ | ||
black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, | ||
Criterion, Throughput, | ||
}; | ||
use rand::{thread_rng, RngCore}; | ||
use simd_adler32::imp::{avx2, avx512, scalar, sse2, ssse3, wasm, Adler32Imp}; | ||
|
||
pub fn bench(c: &mut Criterion) { | ||
let mut data = [0; 100_000]; | ||
let mut group = c.benchmark_group("variants"); | ||
|
||
thread_rng().fill_bytes(&mut data[..]); | ||
|
||
if let Some(update) = avx512::get_imp() { | ||
bench_variant(&mut group, "avx512", &data, update); | ||
} | ||
|
||
if let Some(update) = avx2::get_imp() { | ||
bench_variant(&mut group, "avx2", &data, update); | ||
} | ||
|
||
if let Some(update) = ssse3::get_imp() { | ||
bench_variant(&mut group, "ssse3", &data, update); | ||
} | ||
|
||
if let Some(update) = sse2::get_imp() { | ||
bench_variant(&mut group, "sse2", &data, update); | ||
} | ||
|
||
if let Some(update) = wasm::get_imp() { | ||
bench_variant(&mut group, "wasm", &data, update); | ||
} | ||
|
||
bench_variant(&mut group, "scalar", &data, scalar::update); | ||
} | ||
|
||
fn bench_variant<M>(g: &mut BenchmarkGroup<M>, name: &str, data: &[u8], imp: Adler32Imp) | ||
where | ||
M: Measurement, | ||
{ | ||
g.throughput(Throughput::Bytes(10)).bench_with_input( | ||
format!("{}-10b", name), | ||
&data[..10], | ||
|b, data| b.iter(|| black_box(imp(1, 0, data))), | ||
); | ||
|
||
g.throughput(Throughput::Bytes(10_000)).bench_with_input( | ||
format!("{}-10k", name), | ||
&data[..10_000], | ||
|b, data| b.iter(|| black_box(imp(1, 0, data))), | ||
); | ||
|
||
g.throughput(Throughput::Bytes(100_000)).bench_with_input( | ||
format!("{}-100k", name), | ||
&data[..100_000], | ||
|b, data| b.iter(|| black_box(imp(1, 0, data))), | ||
); | ||
} | ||
|
||
criterion_group!(benches, bench); | ||
criterion_main!(benches); |