Add benchmark for mul_assign

This commit is contained in:
Eirik Ogilvie-Wigley 2018-09-05 14:47:11 -06:00
parent a08e45c4aa
commit a00f0e3525
2 changed files with 21 additions and 0 deletions

17
benches/fq_bench.rs Normal file
View File

@ -0,0 +1,17 @@
#![feature(test)]
extern crate test;
extern crate jubjub;
use std::ops::MulAssign;
use test::Bencher;
use jubjub::Fq;
#[bench]
fn bench_mul_assign(bencher: &mut Bencher) {
let mut n = Fq::new([2, 2, 2, 2]);
let m = Fq::new([2, 2, 2, 2]);
bencher.iter(move || {
n.mul_assign(&m);
});
}

View File

@ -186,6 +186,10 @@ const R2: Fq = Fq([
]);
impl Fq {
pub fn new(limbs: [u64; 4]) -> Fq {
Fq(limbs)
}
pub fn zero() -> Fq {
Fq([0, 0, 0, 0])
}