Skip to content

Commit

Permalink
Add benches for sha256 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
th4s authored Sep 26, 2023
1 parent 960e41d commit c5dd879
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mpz-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ itybity.workspace = true

[dev-dependencies]
aes.workspace = true
criterion.workspace = true

[[bench]]
name = "sha256"
harness = false

27 changes: 27 additions & 0 deletions mpz-circuits/benches/sha256.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use mpz_circuits::{circuits::build_sha256, types::Value};

fn criterion_benchmark(c: &mut Criterion) {
let length = 512;

c.bench_function("build_sha256", move |bench| {
bench.iter(|| black_box(build_sha256(0, length)))
});

let sha256 = build_sha256(0, length);
c.bench_function("compute_sha256", |bench| {
bench.iter(|| {
black_box(
sha256
.evaluate(&[
Value::Array(vec![Value::U32(0); 8]),
Value::Array(vec![Value::U8(0); length]),
])
.unwrap(),
)
})
});
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);

0 comments on commit c5dd879

Please sign in to comment.