Browse Source

Add benchmark for sub_assign (#41)

reduce-generics
Dev Ojha 3 years ago
committed by GitHub
parent
commit
684969909b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      curve-benches/src/macros/ec.rs

+ 19
- 0
curve-benches/src/macros/ec.rs

@ -42,6 +42,24 @@ macro_rules! ec_bench {
});
}
fn sub_assign(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
let v: Vec<($projective, $projective)> = (0..SAMPLES)
.map(|_| (<$projective>::rand(&mut rng), <$projective>::rand(&mut rng)))
.collect();
let mut count = 0;
b.iter(|| {
let mut tmp = v[count].0;
n_fold!(tmp, v, sub_assign, count);
count = (count + 1) % SAMPLES;
tmp
});
}
fn double(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -199,6 +217,7 @@ macro_rules! ec_bench {
rand,
mul_assign,
add_assign,
sub_assign,
add_assign_mixed,
double,
ser,

Loading…
Cancel
Save