Skip to content

Commit 86969de

Browse files
committed
add icount benchmark for u256 NarrowingDiv
1 parent 784d0cf commit 86969de

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

libm-test/benches/icount.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ fn icount_bench_u128_widen_mul(cases: Vec<(u128, u128)>) {
111111
}
112112
}
113113

114+
#[library_benchmark]
115+
#[bench::linspace(setup_u128_mul())]
116+
fn icount_bench_u256_narrowing_div(cases: Vec<(u128, u128)>) {
117+
use libm::support::NarrowingDiv;
118+
for (x, y) in cases.iter().copied() {
119+
let x = black_box(x.widen_hi());
120+
let y = black_box(y);
121+
black_box(x.checked_narrowing_div_rem(y));
122+
}
123+
}
124+
114125
#[library_benchmark]
115126
#[bench::linspace(setup_u256_add())]
116127
fn icount_bench_u256_add(cases: Vec<(u256, u256)>) {
@@ -145,7 +156,7 @@ fn icount_bench_u256_shr(cases: Vec<(u256, u32)>) {
145156

146157
library_benchmark_group!(
147158
name = icount_bench_u128_group;
148-
benchmarks = icount_bench_u128_widen_mul, icount_bench_u256_add, icount_bench_u256_sub, icount_bench_u256_shl, icount_bench_u256_shr
159+
benchmarks = icount_bench_u128_widen_mul, icount_bench_u256_narrowing_div, icount_bench_u256_add, icount_bench_u256_sub, icount_bench_u256_shl, icount_bench_u256_shr
149160
);
150161

151162
#[library_benchmark]

0 commit comments

Comments
 (0)