mirror of
https://github.com/vacp2p/zerokit.git
synced 2025-01-18 10:32:22 +00:00
feat(rln): pmtree benchmarks (#169)
* feat(rln): pmtree benchmarks * style(rln): lint
This commit is contained in:
parent
3177e3ae74
commit
b841e725a0
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2678,6 +2678,7 @@ dependencies = [
|
||||
"ark-std 0.4.0",
|
||||
"cfg-if",
|
||||
"color-eyre 0.6.2",
|
||||
"criterion 0.4.0",
|
||||
"include_dir",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
|
@ -3,6 +3,7 @@ name = "rln"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
bench = false
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib", "staticlib"]
|
||||
@ -47,6 +48,7 @@ include_dir = "=0.7.3"
|
||||
|
||||
[dev-dependencies]
|
||||
sled = "=0.34.7"
|
||||
criterion = { version = "0.4", features = ["html_reports"] }
|
||||
|
||||
[features]
|
||||
default = ["parallel", "wasmer/sys-default", "pmtree-ft"]
|
||||
@ -56,3 +58,7 @@ fullmerkletree = ["default"]
|
||||
|
||||
# Note: pmtree feature is still experimental
|
||||
pmtree-ft = ["utils/pmtree-ft"]
|
||||
|
||||
[[bench]]
|
||||
name = "pmtree_benchmark"
|
||||
harness = false
|
||||
|
@ -5,3 +5,7 @@ args = ["build", "--release"]
|
||||
[tasks.test]
|
||||
command = "cargo"
|
||||
args = ["test", "--release"]
|
||||
|
||||
[tasks.bench]
|
||||
command = "cargo"
|
||||
args = ["bench"]
|
||||
|
44
rln/benches/pmtree_benchmark.rs
Normal file
44
rln/benches/pmtree_benchmark.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use utils::ZerokitMerkleTree;
|
||||
|
||||
use rln::{circuit::Fr, pm_tree_adapter::PmTree};
|
||||
|
||||
pub fn pmtree_benchmark(c: &mut Criterion) {
|
||||
let mut tree = PmTree::default(2).unwrap();
|
||||
|
||||
let leaves: Vec<Fr> = (0..4).map(|s| Fr::from(s)).collect();
|
||||
|
||||
c.bench_function("Pmtree::set", |b| {
|
||||
b.iter(|| {
|
||||
tree.set(0, leaves[0]).unwrap();
|
||||
})
|
||||
});
|
||||
|
||||
c.bench_function("Pmtree:delete", |b| {
|
||||
b.iter(|| {
|
||||
tree.delete(0).unwrap();
|
||||
})
|
||||
});
|
||||
|
||||
c.bench_function("Pmtree::override_range", |b| {
|
||||
b.iter(|| {
|
||||
tree.override_range(0, leaves.clone(), [0, 1, 2, 3])
|
||||
.unwrap();
|
||||
})
|
||||
});
|
||||
|
||||
c.bench_function("Pmtree::compute_root", |b| {
|
||||
b.iter(|| {
|
||||
tree.compute_root().unwrap();
|
||||
})
|
||||
});
|
||||
|
||||
c.bench_function("Pmtree::get", |b| {
|
||||
b.iter(|| {
|
||||
tree.get(0).unwrap();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, pmtree_benchmark);
|
||||
criterion_main!(benches);
|
@ -5,3 +5,7 @@ args = ["build", "--release"]
|
||||
[tasks.test]
|
||||
command = "cargo"
|
||||
args = ["test", "--release"]
|
||||
|
||||
[tasks.bench]
|
||||
command = "cargo"
|
||||
args = ["bench"]
|
Loading…
x
Reference in New Issue
Block a user