From 684969909b6ac473a48ccc9ba5ddf90c8daeee4e Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Thu, 4 Feb 2021 15:50:08 -0600 Subject: [PATCH] Add benchmark for sub_assign (#41) --- curve-benches/src/macros/ec.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/curve-benches/src/macros/ec.rs b/curve-benches/src/macros/ec.rs index 9c1abe8..9241a14 100644 --- a/curve-benches/src/macros/ec.rs +++ b/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,