mirror of https://github.com/zcash/halo2.git
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
|
#[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);
|