Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to criterion 0.5 #375

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ clear_on_drop = { version = "0.2", default-features = false }

[dev-dependencies]
hex = "0.3"
criterion = "0.3"
criterion = "0.5"
bincode = "1"
rand_chacha = "0.2"

Expand Down
17 changes: 8 additions & 9 deletions benches/generators.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use bulletproofs::{BulletproofGens, PedersenGens};

#[macro_use]
extern crate criterion;
use criterion::Criterion;
use criterion::BenchmarkId;
use criterion::{criterion_group, criterion_main, Criterion};

fn pc_gens(c: &mut Criterion) {
c.bench_function("PedersenGens::new", |b| b.iter(|| PedersenGens::default()));
}

fn bp_gens(c: &mut Criterion) {
c.bench_function_over_inputs(
"BulletproofGens::new",
|b, size| b.iter(|| BulletproofGens::new(*size, 1)),
(0..10).map(|i| 2 << i),
);
let mut group = c.benchmark_group("BulletproofGens::new");
for size in (0..10).map(|i| 2 << i) {
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, &size| {
b.iter(|| BulletproofGens::new(size, 1))
});
}
}

criterion_group! {
Expand Down
4 changes: 1 addition & 3 deletions benches/r1cs.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![allow(non_snake_case)]

#[macro_use]
extern crate criterion;
use criterion::Criterion;
use criterion::{criterion_group, criterion_main, Criterion};

// Code below copied from ../tests/r1cs.rs
//
Expand Down
27 changes: 12 additions & 15 deletions benches/range_proof.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(non_snake_case)]
#[macro_use]
extern crate criterion;
use criterion::Criterion;
use criterion::BenchmarkId;
use criterion::{criterion_group, criterion_main, Criterion};

use rand;
use rand::Rng;
Expand All @@ -17,10 +16,10 @@ static AGGREGATION_SIZES: [usize; 6] = [1, 2, 4, 8, 16, 32];

fn create_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
let label = format!("Aggregated {}-bit rangeproof creation", n);
let mut group = c.benchmark_group(&label);

c.bench_function_over_inputs(
&label,
move |b, &&m| {
for size in AGGREGATION_SIZES {
group.bench_with_input(BenchmarkId::from_parameter(size), &size, move |b, &m| {
let pc_gens = PedersenGens::default();
let bp_gens = BulletproofGens::new(n, m);
let mut rng = rand::thread_rng();
Expand All @@ -42,9 +41,8 @@ fn create_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
n,
)
})
},
&AGGREGATION_SIZES,
);
});
}
}

fn create_aggregated_rangeproof_n_8(c: &mut Criterion) {
Expand All @@ -65,10 +63,10 @@ fn create_aggregated_rangeproof_n_64(c: &mut Criterion) {

fn verify_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
let label = format!("Aggregated {}-bit rangeproof verification", n);
let mut group = c.benchmark_group(&label);

c.bench_function_over_inputs(
&label,
move |b, &&m| {
for size in AGGREGATION_SIZES {
group.bench_with_input(BenchmarkId::from_parameter(size), &size, move |b, &m| {
let pc_gens = PedersenGens::default();
let bp_gens = BulletproofGens::new(n, m);
let mut rng = rand::thread_rng();
Expand All @@ -94,9 +92,8 @@ fn verify_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {

proof.verify_multiple(&bp_gens, &pc_gens, &mut transcript, &value_commitments, n)
});
},
&AGGREGATION_SIZES,
);
});
}
}

fn verify_aggregated_rangeproof_n_8(c: &mut Criterion) {
Expand Down