Skip to content

Commit

Permalink
Leverage support for units in benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Nov 5, 2024
1 parent 0ca5d23 commit 3378d7c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ readme = "README.md"
version = "0.1"

[build-dependencies]
cc = "1.1.31"
cc = "1.1.34"

[dev-dependencies]
benchmark-simple = "0.1.9"
benchmark-simple = "0.1.10"
ascon-aead = "0.4.2"
aes-gcm = "0.10.3"
chacha20poly1305 = "0.10.1"
Expand Down
90 changes: 72 additions & 18 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,29 +171,47 @@ fn main() {

let state = Aegis128X4Mac::<32>::new(&[0u8; 16]);
let res = bench.run(options, || test_aegis128x4_mac(&state, &m));
println!("aegis128x4-mac : {}", res.throughput(m.len() as _));
println!(
"aegis128x4-mac : {}",
res.throughput_bits(m.len() as _)
);

let state = Aegis128X2Mac::<32>::new(&[0u8; 16]);
let res = bench.run(options, || test_aegis128x2_mac(&state, &m));
println!("aegis128x2-mac : {}", res.throughput(m.len() as _));
println!(
"aegis128x2-mac : {}",
res.throughput_bits(m.len() as _)
);

let state = Aegis128LMac::<32>::new(&[0u8; 16]);
let res = bench.run(options, || test_aegis128l_mac(&state, &m));
println!("aegis128l-mac : {}", res.throughput(m.len() as _));
println!(
"aegis128l-mac : {}",
res.throughput_bits(m.len() as _)
);

let sthash = sthash::Hasher::new(sthash::Key::from_seed(&[0u8; 32], None), None);
let res = bench.run(options, || sthash.hash(&m));
println!("sthash : {}", res.throughput(m.len() as _));
println!(
"sthash : {}",
res.throughput_bits(m.len() as _)
);

#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
{
let res = bench.run(options, || test_hmac_sha256(&m));
println!("hmac-sha256 (boring): {}", res.throughput(m.len() as _));
println!(
"hmac-sha256 (boring): {}",
res.throughput_bits(m.len() as _)
);
}

let b3 = blake3::Hasher::new_keyed(&[0u8; 32]);
let res = bench.run(options, || b3.clone().update(&m).finalize());
println!("blake3 : {}", res.throughput(m.len() as _));
println!(
"blake3 : {}",
res.throughput_bits(m.len() as _)
);

println!();
}
Expand All @@ -206,48 +224,84 @@ fn main() {
#[cfg(not(feature = "pure-rust"))]
{
let res = bench.run(options, || test_aegis128x4(&mut m));
println!("aegis128x4 : {}", res.throughput(m.len() as _));
println!(
"aegis128x4 : {}",
res.throughput_bits(m.len() as _)
);

let res = bench.run(options, || test_aegis128x2(&mut m));
println!("aegis128x2 : {}", res.throughput(m.len() as _));
println!(
"aegis128x2 : {}",
res.throughput_bits(m.len() as _)
);
}

let res = bench.run(options, || test_aegis128l(&mut m));
println!("aegis128l : {}", res.throughput(m.len() as _));
println!(
"aegis128l : {}",
res.throughput_bits(m.len() as _)
);

#[cfg(not(feature = "pure-rust"))]
{
let res = bench.run(options, || test_aegis256x2(&mut m));
println!("aegis256x2 : {}", res.throughput(m.len() as _));
println!(
"aegis256x2 : {}",
res.throughput_bits(m.len() as _)
);

let res = bench.run(options, || test_aegis256x4(&mut m));
println!("aegis256x4 : {}", res.throughput(m.len() as _));
println!(
"aegis256x4 : {}",
res.throughput_bits(m.len() as _)
);
}

let res = bench.run(options, || test_aegis256(&mut m));
println!("aegis256 : {}", res.throughput(m.len() as _));
println!(
"aegis256 : {}",
res.throughput_bits(m.len() as _)
);

let res = bench.run(options, || test_aes128gcm(&mut m));
println!("aes128-gcm (aes-gcm): {}", res.throughput(m.len() as _));
println!(
"aes128-gcm (aes-gcm): {}",
res.throughput_bits(m.len() as _)
);

#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
{
let res = bench.run(options, || test_aes128gcm_boringssl(&mut m));
println!("aes128-gcm (boring) : {}", res.throughput(m.len() as _));
println!(
"aes128-gcm (boring) : {}",
res.throughput_bits(m.len() as _)
);
}

let res = bench.run(options, || test_aes256gcm(&mut m));
println!("aes256-gcm (aes-gcm): {}", res.throughput(m.len() as _));
println!(
"aes256-gcm (aes-gcm): {}",
res.throughput_bits(m.len() as _)
);

#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
{
let res = bench.run(options, || test_aes256gcm_boringssl(&mut m));
println!("aes256-gcm (boring) : {}", res.throughput(m.len() as _));
println!(
"aes256-gcm (boring) : {}",
res.throughput_bits(m.len() as _)
);
}

let res = bench.run(options, || test_chacha20poly1305(&mut m));
println!("chacha20-poly1305 : {}", res.throughput(m.len() as _));
println!(
"chacha20-poly1305 : {}",
res.throughput_bits(m.len() as _)
);

let res = bench.run(options, || test_ascon128a(&mut m));
println!("ascon128a : {}", res.throughput(m.len() as _));
println!(
"ascon128a : {}",
res.throughput_bits(m.len() as _)
);
}

0 comments on commit 3378d7c

Please sign in to comment.