|
@ -31,7 +31,7 @@ macro_rules! f_bench { |
|
|
repr_div2,
|
|
|
repr_div2,
|
|
|
into_repr,
|
|
|
into_repr,
|
|
|
from_repr,
|
|
|
from_repr,
|
|
|
);
|
|
|
|
|
|
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
use $modname::$modname;
|
|
|
use $modname::$modname;
|
|
|
};
|
|
|
};
|
|
@ -57,7 +57,7 @@ macro_rules! f_bench { |
|
|
deser_unchecked,
|
|
|
deser_unchecked,
|
|
|
// sqrt field stuff
|
|
|
// sqrt field stuff
|
|
|
sqrt,
|
|
|
sqrt,
|
|
|
);
|
|
|
|
|
|
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
use $modname::$modname;
|
|
|
use $modname::$modname;
|
|
|
};
|
|
|
};
|
|
@ -80,7 +80,7 @@ macro_rules! f_bench { |
|
|
deser,
|
|
|
deser,
|
|
|
ser_unchecked,
|
|
|
ser_unchecked,
|
|
|
deser_unchecked,
|
|
|
deser_unchecked,
|
|
|
);
|
|
|
|
|
|
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
use $modname::$modname;
|
|
|
use $modname::$modname;
|
|
|
};
|
|
|
};
|
|
@ -107,7 +107,6 @@ macro_rules! field_common { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn sub_assign(b: &mut $crate::bencher::Bencher) {
|
|
|
fn sub_assign(b: &mut $crate::bencher::Bencher) {
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
|
|
|
|
|
@ -142,7 +141,6 @@ macro_rules! field_common { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn negate(b: &mut $crate::bencher::Bencher) {
|
|
|
fn negate(b: &mut $crate::bencher::Bencher) {
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
|
|
|
|
|
@ -193,7 +191,6 @@ macro_rules! field_common { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn inverse(b: &mut $crate::bencher::Bencher) {
|
|
|
fn inverse(b: &mut $crate::bencher::Bencher) {
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
|
|
|
|
|
@ -209,21 +206,22 @@ macro_rules! field_common { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn deser(b: &mut $crate::bencher::Bencher) {
|
|
|
fn deser(b: &mut $crate::bencher::Bencher) {
|
|
|
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
|
|
|
|
|
|
|
|
|
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
|
|
|
|
|
|
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
|
|
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
|
|
|
|
|
|
|
|
let mut num_bytes = 0;
|
|
|
let mut num_bytes = 0;
|
|
|
let v: Vec<_> = (0..SAMPLES).flat_map(|_| {
|
|
|
|
|
|
let mut bytes = Vec::with_capacity(1000);
|
|
|
|
|
|
let tmp = $f::rand(&mut rng);
|
|
|
|
|
|
tmp.serialize(&mut bytes).unwrap();
|
|
|
|
|
|
num_bytes = bytes.len();
|
|
|
|
|
|
bytes
|
|
|
|
|
|
}).collect();
|
|
|
|
|
|
|
|
|
let v: Vec<_> = (0..SAMPLES)
|
|
|
|
|
|
.flat_map(|_| {
|
|
|
|
|
|
let mut bytes = Vec::with_capacity(1000);
|
|
|
|
|
|
let tmp = $f::rand(&mut rng);
|
|
|
|
|
|
tmp.serialize(&mut bytes).unwrap();
|
|
|
|
|
|
num_bytes = bytes.len();
|
|
|
|
|
|
bytes
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
let mut count = 0;
|
|
|
b.iter(|| {
|
|
|
b.iter(|| {
|
|
@ -233,7 +231,6 @@ macro_rules! field_common { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn ser(b: &mut $crate::bencher::Bencher) {
|
|
|
fn ser(b: &mut $crate::bencher::Bencher) {
|
|
|
use ark_serialize::CanonicalSerialize;
|
|
|
use ark_serialize::CanonicalSerialize;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
@ -249,25 +246,25 @@ macro_rules! field_common { |
|
|
count = (count + 1) % SAMPLES;
|
|
|
count = (count + 1) % SAMPLES;
|
|
|
bytes.clear();
|
|
|
bytes.clear();
|
|
|
tmp.serialize(&mut bytes)
|
|
|
tmp.serialize(&mut bytes)
|
|
|
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn deser_unchecked(b: &mut $crate::bencher::Bencher) {
|
|
|
fn deser_unchecked(b: &mut $crate::bencher::Bencher) {
|
|
|
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
|
|
|
|
|
|
|
|
|
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
|
|
|
|
|
|
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
|
|
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
|
|
|
|
|
|
|
|
let mut num_bytes = 0;
|
|
|
let mut num_bytes = 0;
|
|
|
let v: Vec<_> = (0..SAMPLES).flat_map(|_| {
|
|
|
|
|
|
let mut bytes = Vec::with_capacity(1000);
|
|
|
|
|
|
let tmp = $f::rand(&mut rng);
|
|
|
|
|
|
tmp.serialize_unchecked(&mut bytes).unwrap();
|
|
|
|
|
|
num_bytes = bytes.len();
|
|
|
|
|
|
bytes
|
|
|
|
|
|
}).collect();
|
|
|
|
|
|
|
|
|
let v: Vec<_> = (0..SAMPLES)
|
|
|
|
|
|
.flat_map(|_| {
|
|
|
|
|
|
let mut bytes = Vec::with_capacity(1000);
|
|
|
|
|
|
let tmp = $f::rand(&mut rng);
|
|
|
|
|
|
tmp.serialize_unchecked(&mut bytes).unwrap();
|
|
|
|
|
|
num_bytes = bytes.len();
|
|
|
|
|
|
bytes
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
let mut count = 0;
|
|
|
b.iter(|| {
|
|
|
b.iter(|| {
|
|
@ -277,7 +274,6 @@ macro_rules! field_common { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn ser_unchecked(b: &mut $crate::bencher::Bencher) {
|
|
|
fn ser_unchecked(b: &mut $crate::bencher::Bencher) {
|
|
|
use ark_serialize::CanonicalSerialize;
|
|
|
use ark_serialize::CanonicalSerialize;
|
|
|
const SAMPLES: usize = 1000;
|
|
|
const SAMPLES: usize = 1000;
|
|
@ -293,10 +289,9 @@ macro_rules! field_common { |
|
|
count = (count + 1) % SAMPLES;
|
|
|
count = (count + 1) % SAMPLES;
|
|
|
bytes.clear();
|
|
|
bytes.clear();
|
|
|
tmp.serialize_unchecked(&mut bytes)
|
|
|
tmp.serialize_unchecked(&mut bytes)
|
|
|
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
#[macro_export]
|
|
@ -313,7 +308,7 @@ macro_rules! sqrt { |
|
|
tmp.square_in_place();
|
|
|
tmp.square_in_place();
|
|
|
tmp
|
|
|
tmp
|
|
|
})
|
|
|
})
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
let mut count = 0;
|
|
|
b.iter(|| {
|
|
|
b.iter(|| {
|
|
@ -321,7 +316,7 @@ macro_rules! sqrt { |
|
|
v[count].sqrt()
|
|
|
v[count].sqrt()
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
#[macro_export]
|
|
@ -343,7 +338,7 @@ macro_rules! prime_field { |
|
|
}
|
|
|
}
|
|
|
(tmp1, tmp2)
|
|
|
(tmp1, tmp2)
|
|
|
})
|
|
|
})
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
let mut count = 0;
|
|
|
b.iter(|| {
|
|
|
b.iter(|| {
|
|
@ -369,7 +364,7 @@ macro_rules! prime_field { |
|
|
}
|
|
|
}
|
|
|
(tmp1, tmp2)
|
|
|
(tmp1, tmp2)
|
|
|
})
|
|
|
})
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
let mut count = 0;
|
|
|
b.iter(|| {
|
|
|
b.iter(|| {
|
|
@ -456,5 +451,5 @@ macro_rules! prime_field { |
|
|
$f::from(v[count]);
|
|
|
$f::from(v[count]);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
};
|
|
|
}
|
|
|
}
|