2020-09-15 09:44:56 -07:00
|
|
|
#[macro_use]
|
|
|
|
extern crate criterion;
|
|
|
|
|
|
|
|
extern crate halo2;
|
2020-11-12 16:08:08 -08:00
|
|
|
use crate::arithmetic::{small_multiexp, FieldExt};
|
2020-09-15 09:44:56 -07:00
|
|
|
use crate::poly::commitment::Params;
|
|
|
|
use crate::transcript::DummyHash;
|
2020-11-12 12:13:13 -08:00
|
|
|
use crate::tweedle::{EqAffine, Fp, Fq};
|
2020-09-15 09:44:56 -07:00
|
|
|
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);
|
|
|
|
|
2020-11-12 16:08:08 -08:00
|
|
|
let coeff_1 = Fp::rand();
|
|
|
|
let coeff_2 = Fp::rand();
|
2020-09-15 09:44:56 -07:00
|
|
|
|
|
|
|
c.bench_function("double-and-add", |b| {
|
|
|
|
b.iter(|| {
|
|
|
|
for (g_lo, g_hi) in g_lo.iter().zip(g_hi.iter()) {
|
2020-09-15 10:07:45 -07:00
|
|
|
small_multiexp(&[black_box(coeff_1), black_box(coeff_2)], &[*g_lo, *g_hi]);
|
2020-09-15 09:44:56 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
|
|
criterion_main!(benches);
|