forked from iron-fish/bellman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslow.rs
47 lines (42 loc) · 1.29 KB
/
slow.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use bellman::{
multicore::Worker,
multiexp::{multiexp, FullDensity},
};
use bls12_381::{Bls12, Scalar};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use ff::{Field, PrimeFieldBits};
use group::{Curve, Group};
use pairing::Engine;
use rand_core::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::sync::Arc;
fn bench_parts(c: &mut Criterion) {
let mut rng = XorShiftRng::from_seed([7; 16]);
let samples = 1 << 16;
let v = Arc::new(
(0..samples)
.map(|_| Scalar::random(&mut rng))
.collect::<Vec<_>>(),
);
let v_bits = Arc::new(v.iter().map(|e| e.to_le_bits()).collect::<Vec<_>>());
let g = Arc::new(
(0..samples)
.map(|_| <Bls12 as Engine>::G1::random(&mut rng).to_affine())
.collect::<Vec<_>>(),
);
let pool = Worker::new();
c.bench_with_input(
BenchmarkId::new("multiexp", samples),
&(pool, g, v_bits),
|b, (pool, g, v_bits)| {
b.iter(|| {
let _: <Bls12 as Engine>::G1 =
multiexp(pool, (g.clone(), 0), FullDensity, v_bits.clone())
.wait()
.unwrap();
})
},
);
}
criterion_group!(benches, bench_parts);
criterion_main!(benches);