add u256_rem_small

This commit is contained in:
Andronik Ordian 2019-04-16 15:41:40 +02:00
parent 8256014422
commit 726b7c69ad
No known key found for this signature in database
GPG Key ID: C66F3C680DE0E6ED
1 changed files with 17 additions and 0 deletions

View File

@ -45,6 +45,7 @@ criterion_group!(
u256_mul_full,
u256_div,
u256_rem,
u256_rem_small,
u256_bit_and,
u256_bit_or,
u256_bit_xor,
@ -160,6 +161,22 @@ fn bench_u256_rem(b: &mut Bencher) {
});
}
fn u256_rem_small(b: &mut Criterion) {
b.bench_function("u256_rem_small", |b| bench_u256_rem_small(b));
}
fn bench_u256_rem_small(b: &mut Bencher) {
let x =
U256::from_str("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF").unwrap();
let y =
U256::from_str("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF").unwrap();
let z = U256::from(1u64);
b.iter(|| {
let w = black_box(x.overflowing_mul(y)).0;
black_box(w % z);
});
}
fn u512_add(b: &mut Criterion) {
b.bench_function("u512_add", |b| bench_u512_add(b));
}