jubjub/benches/point_bench.rs

59 lines
1.3 KiB
Rust
Raw Normal View History

#![feature(test)]
extern crate test;
use jubjub::*;
use test::Bencher;
2019-01-07 18:07:55 -08:00
// Non-Niels
#[bench]
fn bench_point_doubling(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
bencher.iter(move || a.double());
}
2019-01-07 18:07:55 -08:00
#[bench]
fn bench_point_addition(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
let b = -ExtendedPoint::identity();
bencher.iter(move || a + b);
}
#[bench]
fn bench_point_subtraction(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
let b = -ExtendedPoint::identity();
bencher.iter(move || a + b);
}
// Niels
#[bench]
fn bench_cached_point_addition(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
2019-01-07 18:07:55 -08:00
let b = ExtendedPoint::identity().to_niels();
bencher.iter(move || &a + &b);
}
#[bench]
fn bench_cached_affine_point_subtraction(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
2019-01-07 18:07:55 -08:00
let b = AffinePoint::identity().to_niels();
bencher.iter(move || &a + &b);
}
#[bench]
fn bench_cached_point_subtraction(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
2019-01-07 18:07:55 -08:00
let b = ExtendedPoint::identity().to_niels();
bencher.iter(move || &a + &b);
}
#[bench]
fn bench_cached_affine_point_addition(bencher: &mut Bencher) {
let a = ExtendedPoint::identity();
2019-01-07 18:07:55 -08:00
let b = AffinePoint::identity().to_niels();
bencher.iter(move || &a + &b);
}