Skip to content
Snippets Groups Projects
Verified Commit 8c91c6d8 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

split the setup of Komodo and the serde benchmarks

parent 0163c8f9
No related branches found
No related tags found
1 merge request!69work on the benchmarks
...@@ -18,13 +18,47 @@ where ...@@ -18,13 +18,47 @@ where
P: DenseUVPolynomial<F>, P: DenseUVPolynomial<F>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>, for<'a, 'b> &'a P: Div<&'b P, Output = P>,
{ {
let mut group = c.benchmark_group("setup");
let rng = &mut rand::thread_rng(); let rng = &mut rand::thread_rng();
group.bench_function(&format!("setup (komodo) {} on {}", degree, curve), |b| { c.bench_function(&format!("setup (komodo) {} on {}", degree, curve), |b| {
b.iter(|| zk::setup::<_, F, G>(degree, rng).unwrap()) b.iter(|| zk::setup::<_, F, G>(degree, rng).unwrap())
}); });
}
fn ark_setup_template<E, P>(c: &mut Criterion, degree: usize, curve: &str)
where
E: Pairing,
P: DenseUVPolynomial<E::ScalarField>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>,
{
let rng = &mut rand::thread_rng();
c.bench_function(
&format!("setup (arkworks) {} bytes on {}", degree, curve),
|b| {
b.iter(|| {
let setup = KZG10::<E, P>::setup(degree, false, rng).unwrap();
let powers_of_g = setup.powers_of_g[..=degree].to_vec();
let powers_of_gamma_g = (0..=degree).map(|i| setup.powers_of_gamma_g[&i]).collect();
kzg10::Powers::<E> {
powers_of_g: ark_std::borrow::Cow::Owned(powers_of_g),
powers_of_gamma_g: ark_std::borrow::Cow::Owned(powers_of_gamma_g),
}
})
},
);
}
fn serde_template<F, G, P>(c: &mut Criterion, degree: usize, curve: &str)
where
F: PrimeField,
G: CurveGroup<ScalarField = F>,
P: DenseUVPolynomial<F>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>,
{
let mut group = c.benchmark_group("setup");
let rng = &mut rand::thread_rng();
let setup = zk::setup::<_, F, G>(degree, rng).unwrap(); let setup = zk::setup::<_, F, G>(degree, rng).unwrap();
...@@ -103,37 +137,30 @@ where ...@@ -103,37 +137,30 @@ where
group.finish(); group.finish();
} }
fn ark_setup_template<E, P>(c: &mut Criterion, degree: usize, curve: &str) fn setup(c: &mut Criterion) {
where fn aux<F: PrimeField, G: CurveGroup<ScalarField = F>>(
E: Pairing, c: &mut Criterion,
P: DenseUVPolynomial<E::ScalarField>, degree: usize,
for<'a, 'b> &'a P: Div<&'b P, Output = P>, curve: &str,
{ ) {
let rng = &mut rand::thread_rng(); setup_template::<F, G, DensePolynomial<F>>(c, black_box(degree), curve);
}
c.bench_function( for n in [1, 2, 4, 8, 16] {
&format!("setup (arkworks) {} bytes on {}", degree, curve), aux::<ark_bls12_381::Fr, ark_bls12_381::G1Projective>(c, n, "BLS-12-381");
|b| { aux::<ark_bn254::Fr, ark_bn254::G1Projective>(c, n, "BN-254");
b.iter(|| { aux::<ark_pallas::Fr, ark_pallas::Projective>(c, n, "PALLAS");
let setup = KZG10::<E, P>::setup(degree, false, rng).unwrap(); }
let powers_of_g = setup.powers_of_g[..=degree].to_vec();
let powers_of_gamma_g = (0..=degree).map(|i| setup.powers_of_gamma_g[&i]).collect();
kzg10::Powers::<E> {
powers_of_g: ark_std::borrow::Cow::Owned(powers_of_g),
powers_of_gamma_g: ark_std::borrow::Cow::Owned(powers_of_gamma_g),
}
})
},
);
} }
fn setup(c: &mut Criterion) {
fn serde(c: &mut Criterion) {
fn aux<F: PrimeField, G: CurveGroup<ScalarField = F>>( fn aux<F: PrimeField, G: CurveGroup<ScalarField = F>>(
c: &mut Criterion, c: &mut Criterion,
degree: usize, degree: usize,
curve: &str, curve: &str,
) { ) {
setup_template::<F, G, DensePolynomial<F>>(c, black_box(degree), curve); serde_template::<F, G, DensePolynomial<F>>(c, black_box(degree), curve);
} }
for n in [1, 2, 4, 8, 16] { for n in [1, 2, 4, 8, 16] {
...@@ -159,6 +186,6 @@ criterion_group!( ...@@ -159,6 +186,6 @@ criterion_group!(
config = Criterion::default() config = Criterion::default()
.warm_up_time(Duration::from_secs_f32(0.5)) .warm_up_time(Duration::from_secs_f32(0.5))
.sample_size(10); .sample_size(10);
targets = setup, ark_setup targets = setup, ark_setup, serde
); );
criterion_main!(benches); criterion_main!(benches);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment