Add benchmarks with criterion.

This commit is contained in:
Sean Bowe 2019-08-11 11:17:37 -06:00
parent 352fa7072a
commit a0572c7ad7
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
2 changed files with 56 additions and 0 deletions

View File

@ -12,6 +12,14 @@ edition = "2018"
[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "katex-header.html" ]
[dev-dependencies]
criterion = "0.2.11"
[[bench]]
name = "groups"
harness = false
required-features = ["groups"]
[dependencies.subtle]
version = "2.1"
default-features = false

48
benches/groups.rs Normal file
View File

@ -0,0 +1,48 @@
#[macro_use]
extern crate criterion;
extern crate bls12_381;
use bls12_381::*;
use criterion::{black_box, Criterion};
fn criterion_benchmark(c: &mut Criterion) {
// G1Affine
{
let name = "G1Affine";
let a = G1Affine::generator();
c.bench_function(&format!("{} check on curve", name), move |b| {
b.iter(|| black_box(a).is_on_curve())
});
}
// G1Projective
{
let name = "G1Projective";
let a = G1Projective::generator();
c.bench_function(&format!("{} check on curve", name), move |b| {
b.iter(|| black_box(a).is_on_curve())
});
}
// G2Affine
{
let name = "G2Affine";
let a = G2Affine::generator();
c.bench_function(&format!("{} check on curve", name), move |b| {
b.iter(|| black_box(a).is_on_curve())
});
}
// G2Projective
{
let name = "G2Projective";
let a = G2Projective::generator();
c.bench_function(&format!("{} check on curve", name), move |b| {
b.iter(|| black_box(a).is_on_curve())
});
}
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);