-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c12eaf0
commit 3119d84
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#![feature(iter_array_chunks)] | ||
|
||
use criterion::Criterion; | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
pub fn cpu_merkle(c: &mut criterion::Criterion) { | ||
use itertools::Itertools; | ||
use num_traits::Zero; | ||
use stwo::commitment_scheme::ops::MerkleOps; | ||
use stwo::core::backend::CPUBackend; | ||
use stwo::core::fields::m31::BaseField; | ||
|
||
const N_COLS: usize = 1 << 8; | ||
const LOG_SIZE: u32 = 20; | ||
let cols = (0..N_COLS) | ||
.map(|_| { | ||
(0..(1 << LOG_SIZE)) | ||
.map(|_| BaseField::zero()) | ||
.collect::<Vec<_>>() | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
let mut group = c.benchmark_group("merkle throughput"); | ||
group.throughput(criterion::Throughput::Elements((N_COLS << LOG_SIZE) as u64)); | ||
group.throughput(criterion::Throughput::Bytes( | ||
(N_COLS << (LOG_SIZE + 2)) as u64, | ||
)); | ||
group.bench_function("cpu merkle", |b| { | ||
b.iter(|| { | ||
CPUBackend::commit_on_layer(LOG_SIZE, None, &cols.iter().collect_vec()); | ||
}) | ||
}); | ||
} | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
criterion::criterion_group!( | ||
name=merkle; | ||
config = Criterion::default().sample_size(10); | ||
targets=cpu_merkle); | ||
criterion::criterion_main!(merkle); |