1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00
azalea/azalea-crypto/benches/my_benchmark.rs
mat e46577a214
Fix connection writer being locked (#23)
* Split connection struct in az-protocol

* az-client uses split conns

* fix errors

* add a convenience write_packet fn to az-client
2022-09-19 21:21:46 -05:00

24 lines
680 B
Rust

use azalea_crypto::{create_cipher, decrypt_packet, encrypt_packet};
use criterion::{criterion_group, criterion_main, Criterion};
fn bench(c: &mut Criterion) {
let (mut 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 64kb", |b| {
b.iter(|| encrypt_packet(&mut enc.clone(), &mut packet.clone()))
});
encrypt_packet(&mut enc, &mut packet);
c.bench_function("Decrypt 64kb", |b| {
b.iter(|| decrypt_packet(&mut dec.clone(), &mut packet.clone()))
});
}
criterion_group!(benches, bench);
criterion_main!(benches);