Update crypto_bench.rs

This commit is contained in:
Alexey
2026-06-28 15:42:53 +03:00
parent d67e7c5a6f
commit 1f2910f5bc
+15 -3
View File
@@ -1,12 +1,24 @@
// Cryptobench use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{Criterion, black_box, criterion_group}; use std::hint::black_box;
#[allow(unused_imports)]
#[path = "../src/error.rs"]
mod error;
#[allow(unused_imports)]
#[path = "../src/crypto/aes.rs"]
mod aes_impl;
use aes_impl::AesCtr;
fn bench_aes_ctr(c: &mut Criterion) { fn bench_aes_ctr(c: &mut Criterion) {
c.bench_function("aes_ctr_encrypt_64kb", |b| { c.bench_function("aes_ctr_encrypt_64kb", |b| {
let data = vec![0u8; 65536]; let data = vec![0u8; 65536];
b.iter(|| { b.iter(|| {
let mut enc = AesCtr::new(&[0u8; 32], 0); let mut enc = AesCtr::new(&[0u8; 32], 0);
black_box(enc.encrypt(&data)) black_box(enc.encrypt(black_box(data.as_slice())))
}) })
}); });
} }
criterion_group!(benches, bench_aes_ctr);
criterion_main!(benches);