librustzcash/jubjub/benches/point_bench.rs

74 lines
2.1 KiB
Rust
Raw Normal View History

2019-12-19 13:55:01 -08:00
use criterion::{criterion_group, criterion_main, Criterion};
use jubjub::*;
// Non-Niels
2019-12-19 13:55:01 -08:00
fn bench_point_doubling(c: &mut Criterion) {
let a = ExtendedPoint::identity();
2019-12-19 13:55:01 -08:00
c.bench_function("Jubjub point doubling", |bencher| {
bencher.iter(move || a.double())
});
}
2019-12-19 13:55:01 -08:00
fn bench_point_addition(c: &mut Criterion) {
let a = ExtendedPoint::identity();
let b = -ExtendedPoint::identity();
2019-12-19 13:55:01 -08:00
c.bench_function("Jubjub point addition", |bencher| {
bencher.iter(move || a + b)
});
}
2019-12-19 13:55:01 -08:00
fn bench_point_subtraction(c: &mut Criterion) {
let a = ExtendedPoint::identity();
let b = -ExtendedPoint::identity();
2019-12-19 13:55:01 -08:00
c.bench_function("Jubjub point subtraction", |bencher| {
bencher.iter(move || a + b)
});
}
// Niels
2019-12-19 13:55:01 -08:00
fn bench_cached_point_addition(c: &mut Criterion) {
let a = ExtendedPoint::identity();
let b = ExtendedPoint::identity().to_niels();
2019-12-19 13:55:01 -08:00
c.bench_function("Jubjub cached point addition", |bencher| {
bencher.iter(move || a + b)
});
}
2019-12-19 13:55:01 -08:00
fn bench_cached_point_subtraction(c: &mut Criterion) {
let a = ExtendedPoint::identity();
2019-12-19 13:55:01 -08:00
let b = ExtendedPoint::identity().to_niels();
c.bench_function("Jubjub cached point subtraction", |bencher| {
bencher.iter(move || a + b)
});
}
2019-12-19 13:55:01 -08:00
fn bench_cached_affine_point_addition(c: &mut Criterion) {
let a = ExtendedPoint::identity();
2019-12-19 13:55:01 -08:00
let b = AffinePoint::identity().to_niels();
c.bench_function("Jubjub cached affine point addition", |bencher| {
bencher.iter(move || a + b)
});
}
2019-12-19 13:55:01 -08:00
fn bench_cached_affine_point_subtraction(c: &mut Criterion) {
let a = ExtendedPoint::identity();
let b = AffinePoint::identity().to_niels();
2019-12-19 13:55:01 -08:00
c.bench_function("Jubjub cached affine point subtraction", |bencher| {
bencher.iter(move || a + b)
});
}
2019-12-19 13:55:01 -08:00
criterion_group!(
benches,
bench_point_doubling,
bench_point_addition,
bench_point_subtraction,
bench_cached_point_addition,
bench_cached_point_subtraction,
bench_cached_affine_point_addition,
bench_cached_affine_point_subtraction,
);
criterion_main!(benches);