diff options
| author | mat <github@matdoes.dev> | 2022-08-28 15:08:43 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-08-28 15:08:43 -0500 |
| commit | b44f1c84de502c183a5f6c8b444a5d35c0d0378c (patch) | |
| tree | e336ac7d7dc236061c124befe629397c5510008b /azalea-crypto/benches | |
| parent | b8228a036016fa58cab4b00a2e62298df299d41f (diff) | |
| download | azalea-drasl-b44f1c84de502c183a5f6c8b444a5d35c0d0378c.tar.xz | |
encryption benchmark & test
Diffstat (limited to 'azalea-crypto/benches')
| -rw-r--r-- | azalea-crypto/benches/my_benchmark.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/azalea-crypto/benches/my_benchmark.rs b/azalea-crypto/benches/my_benchmark.rs new file mode 100644 index 00000000..2d255d9c --- /dev/null +++ b/azalea-crypto/benches/my_benchmark.rs @@ -0,0 +1,18 @@ +use azalea_crypto::{create_cipher, encrypt_packet}; +use criterion::{criterion_group, criterion_main, Criterion, Throughput}; + +fn bench(c: &mut Criterion) { + let (enc, dec) = create_cipher(b"0123456789abcdef"); + + let mut packet = [0u8; 65536]; + for i in 0..packet.len() { + packet[i] = i as u8; + } + + c.bench_function("Encrypt", |b| { + b.iter(|| encrypt_packet(&mut enc.clone(), &mut packet.clone())) + }); +} + +criterion_group!(benches, bench); +criterion_main!(benches); |
