mirror of https://github.com/vacp2p/zerokit.git
feat(rln): pmtree benchmarks (#169)
* feat(rln): pmtree benchmarks * style(rln): lint
This commit is contained in:
parent
3177e3ae74
commit
b841e725a0
|
@ -2678,6 +2678,7 @@ dependencies = [
|
||||||
"ark-std 0.4.0",
|
"ark-std 0.4.0",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"color-eyre 0.6.2",
|
"color-eyre 0.6.2",
|
||||||
|
"criterion 0.4.0",
|
||||||
"include_dir",
|
"include_dir",
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
|
|
@ -3,6 +3,7 @@ name = "rln"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
bench = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["rlib", "staticlib"]
|
crate-type = ["rlib", "staticlib"]
|
||||||
|
@ -47,6 +48,7 @@ include_dir = "=0.7.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sled = "=0.34.7"
|
sled = "=0.34.7"
|
||||||
|
criterion = { version = "0.4", features = ["html_reports"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["parallel", "wasmer/sys-default", "pmtree-ft"]
|
default = ["parallel", "wasmer/sys-default", "pmtree-ft"]
|
||||||
|
@ -56,3 +58,7 @@ fullmerkletree = ["default"]
|
||||||
|
|
||||||
# Note: pmtree feature is still experimental
|
# Note: pmtree feature is still experimental
|
||||||
pmtree-ft = ["utils/pmtree-ft"]
|
pmtree-ft = ["utils/pmtree-ft"]
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "pmtree_benchmark"
|
||||||
|
harness = false
|
||||||
|
|
|
@ -5,3 +5,7 @@ args = ["build", "--release"]
|
||||||
[tasks.test]
|
[tasks.test]
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
args = ["test", "--release"]
|
args = ["test", "--release"]
|
||||||
|
|
||||||
|
[tasks.bench]
|
||||||
|
command = "cargo"
|
||||||
|
args = ["bench"]
|
||||||
|
|
|
@ -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]
|
[tasks.test]
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
args = ["test", "--release"]
|
args = ["test", "--release"]
|
||||||
|
|
||||||
|
[tasks.bench]
|
||||||
|
command = "cargo"
|
||||||
|
args = ["bench"]
|
Loading…
Reference in New Issue