mirror of
https://github.com/telemt/telemt.git
synced 2026-07-01 23:31:10 +03:00
Update crypto_bench.rs
This commit is contained in:
+15
-3
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user