mirror of
https://github.com/pseXperiments/clookup.git
synced 2026-01-09 03:58:01 -05:00
Update benchmark
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/target
|
||||
|
||||
*.svg
|
||||
*.data*
|
||||
Cargo.lock
|
||||
|
||||
10
Cargo.toml
10
Cargo.toml
@@ -24,3 +24,13 @@ ark-std = { version = "^0.4.0", default-features = false, optional = true }
|
||||
|
||||
# concurrency
|
||||
rayon = "1.8"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.4", features = ["html_reports"] }
|
||||
|
||||
[[bench]]
|
||||
name = "full"
|
||||
harness = false
|
||||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
|
||||
21
Makefile
Normal file
21
Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
prog :=xnixperms
|
||||
|
||||
debug ?=
|
||||
|
||||
$(info debug is $(debug))
|
||||
|
||||
ifdef debug
|
||||
release :=
|
||||
target :=debug
|
||||
extension :=debug
|
||||
else
|
||||
release :=--release
|
||||
target :=release
|
||||
extension :=
|
||||
endif
|
||||
|
||||
build:
|
||||
cargo build $(release)
|
||||
|
||||
bench:
|
||||
cargo flamegraph --bench full
|
||||
@@ -1 +1,9 @@
|
||||
# clookup
|
||||
Lookup argument with function composition
|
||||
|
||||
## Benchmark
|
||||
To run benchmark, run
|
||||
```sh
|
||||
cargo install flamegraph
|
||||
```
|
||||
In Linux, install `perf`.
|
||||
|
||||
51
benches/full.rs
Normal file
51
benches/full.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use std::{cmp::max, io::Cursor};
|
||||
|
||||
use clookup::{core::{precomputation::Table, prover::Prover, verifier::Verifier}, pcs::{multilinear::kzg::MultilinearKzg, PolynomialCommitmentScheme}, utils::{end_timer, random_fe, start_timer, transcript::{InMemoryTranscript, Keccak256Transcript}, ProtocolError}};
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use halo2curves::bn256::{Bn256, Fr};
|
||||
use itertools::Itertools;
|
||||
|
||||
type ClookupProver = Prover<Fr, MultilinearKzg<Bn256>>;
|
||||
type ClookupVerifier = Verifier<Fr, MultilinearKzg<Bn256>>;
|
||||
|
||||
pub fn test_clookup() -> Result<(), ProtocolError> {
|
||||
let table_dim = 8;
|
||||
let witness_dim = 4;
|
||||
let table_vec: Vec<Fr> = (0..1 << table_dim).map(|_| random_fe()).collect_vec();
|
||||
let witness_vec = table_vec
|
||||
.iter()
|
||||
.take(1 << witness_dim)
|
||||
.cloned()
|
||||
.collect_vec();
|
||||
let table: Table<Fr> = table_vec.try_into()?;
|
||||
let max_degree = 1 + max(2, table_dim);
|
||||
let (pp, vp) = {
|
||||
let rng = rand::thread_rng();
|
||||
let param = ClookupProver::setup(&table, &witness_vec, rng)?;
|
||||
MultilinearKzg::trim(¶m, 1 << witness_dim, 1).unwrap()
|
||||
};
|
||||
let timer = start_timer(|| "clookup prover");
|
||||
let proof = {
|
||||
let mut transcript = Keccak256Transcript::<Cursor<Vec<u8>>>::default();
|
||||
ClookupProver::prove(&pp, &mut transcript, &table, &witness_vec)?;
|
||||
transcript.into_proof()
|
||||
};
|
||||
end_timer(timer);
|
||||
let mut transcript =
|
||||
Keccak256Transcript::<Cursor<Vec<u8>>>::from_proof((), proof.as_slice());
|
||||
ClookupVerifier::verify(
|
||||
&vp,
|
||||
&mut transcript,
|
||||
table_dim + 2,
|
||||
table_dim,
|
||||
witness_dim,
|
||||
max_degree,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
c.bench_function("e2e-clookup", |b| b.iter(|| test_clookup()));
|
||||
}
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
Reference in New Issue
Block a user