-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from RustCrypto/avx2-parallel
chacha20: Parallelize AVX2 backend
- Loading branch information
Showing
10 changed files
with
130 additions
and
49 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
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,36 @@ | ||
//! `ChaCha20Rng` benchmark | ||
#[cfg(not(feature = "rng"))] | ||
compile_error!("run benchmarks with `cargo bench --all-features`"); | ||
|
||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; | ||
use criterion_cycles_per_byte::CyclesPerByte; | ||
|
||
use chacha20::ChaCha20Rng; | ||
use rand_core::{RngCore, SeedableRng}; | ||
|
||
const KB: usize = 1024; | ||
|
||
fn bench(c: &mut Criterion<CyclesPerByte>) { | ||
let mut group = c.benchmark_group("rng"); | ||
|
||
for size in &[KB, 2 * KB, 4 * KB, 8 * KB, 16 * KB] { | ||
let mut buf = vec![0u8; *size]; | ||
|
||
group.throughput(Throughput::Bytes(*size as u64)); | ||
|
||
group.bench_function(BenchmarkId::new("apply_keystream", size), |b| { | ||
let mut rng = ChaCha20Rng::from_seed(Default::default()); | ||
b.iter(|| rng.fill_bytes(&mut buf)); | ||
}); | ||
} | ||
|
||
group.finish(); | ||
} | ||
|
||
criterion_group!( | ||
name = benches; | ||
config = Criterion::default().with_measurement(CyclesPerByte); | ||
targets = bench | ||
); | ||
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
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
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
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