mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Add benchmarks for shared double-and-add
This commit is contained in:
parent
f2fc068db0
commit
d70c8cc0d7
3 changed files with 54 additions and 0 deletions
|
|
@ -20,6 +20,13 @@ publish = false
|
|||
[package.metadata.docs.rs]
|
||||
rustdoc-args = [ "--html-in-header", "katex-header.html" ]
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
|
||||
[[bench]]
|
||||
name = "plonk"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
subtle = "2.2.1"
|
||||
crossbeam-utils = "0.7"
|
||||
|
|
|
|||
42
benches/plonk.rs
Normal file
42
benches/plonk.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#[macro_use]
|
||||
extern crate criterion;
|
||||
|
||||
extern crate halo2;
|
||||
use crate::arithmetic::{small_multiexp, EqAffine, Field, Fp, Fq};
|
||||
use crate::poly::commitment::Params;
|
||||
use crate::transcript::DummyHash;
|
||||
use halo2::*;
|
||||
|
||||
use criterion::{black_box, Criterion};
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
// small multiexp
|
||||
{
|
||||
let params: Params<EqAffine> = Params::new::<DummyHash<Fq>>(5);
|
||||
let g = &mut params.get_g();
|
||||
let len = g.len() / 2;
|
||||
let (g_lo, g_hi) = g.split_at_mut(len);
|
||||
|
||||
let coeff_1 = Fp::random();
|
||||
let coeff_2 = Fp::random();
|
||||
|
||||
c.bench_function("shared double-and-add", |b| {
|
||||
b.iter(|| {
|
||||
for (g_lo, g_hi) in g_lo.iter().zip(g_hi.iter()) {
|
||||
small_multiexp(&[black_box(coeff_1), black_box(coeff_2)], &[*g_lo, *g_hi]);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
c.bench_function("double-and-add", |b| {
|
||||
b.iter(|| {
|
||||
for (g_lo, g_hi) in g_lo.iter().zip(g_hi.iter()) {
|
||||
let _ = ((*g_lo) * coeff_1) + &((*g_hi) * coeff_2);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
|
|
@ -261,6 +261,11 @@ impl<C: CurveAffine> Params<C> {
|
|||
other_bases,
|
||||
}
|
||||
}
|
||||
|
||||
/// Getter for g generators
|
||||
pub fn get_g(&self) -> Vec<C> {
|
||||
self.g.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// A guard returned by the verifier
|
||||
|
|
|
|||
Loading…
Reference in a new issue