@@ -219,7 +219,19 @@ fn bench_division(c: &mut Criterion) {
219
219
let mut rng = make_rng ( ) ;
220
220
let mut group = c. benchmark_group ( "wrapping ops" ) ;
221
221
222
- group. bench_function ( "div/rem, U256/U128, full size" , |b| {
222
+ group. bench_function ( "div/rem, U256/U128" , |b| {
223
+ b. iter_batched (
224
+ || {
225
+ let x = U256 :: random ( & mut rng) ;
226
+ let y = U128 :: random ( & mut rng) ;
227
+ ( x, NonZero :: new ( y) . unwrap ( ) )
228
+ } ,
229
+ |( x, y) | black_box ( x. div_rem ( & y) ) ,
230
+ BatchSize :: SmallInput ,
231
+ )
232
+ } ) ;
233
+
234
+ group. bench_function ( "div/rem, U256/U128 (in U256)" , |b| {
223
235
b. iter_batched (
224
236
|| {
225
237
let x = U256 :: random ( & mut rng) ;
@@ -232,6 +244,18 @@ fn bench_division(c: &mut Criterion) {
232
244
)
233
245
} ) ;
234
246
247
+ group. bench_function ( "div/rem, U256/U128 (in U512)" , |b| {
248
+ b. iter_batched (
249
+ || {
250
+ let x = U256 :: random ( & mut rng) ;
251
+ let y: U512 = U128 :: random ( & mut rng) . resize ( ) ;
252
+ ( x, NonZero :: new ( y) . unwrap ( ) )
253
+ } ,
254
+ |( x, y) | black_box ( x. div_rem ( & y) ) ,
255
+ BatchSize :: SmallInput ,
256
+ )
257
+ } ) ;
258
+
235
259
group. bench_function ( "div/rem_vartime, U256/U128, full size" , |b| {
236
260
b. iter_batched (
237
261
|| {
@@ -244,12 +268,35 @@ fn bench_division(c: &mut Criterion) {
244
268
)
245
269
} ) ;
246
270
247
- group. bench_function ( "rem, U256/U128, full size " , |b| {
271
+ group. bench_function ( "rem, U256/U128" , |b| {
248
272
b. iter_batched (
249
273
|| {
250
274
let x = U256 :: random ( & mut rng) ;
251
- let y_half = U128 :: random ( & mut rng) ;
252
- let y: U256 = ( y_half, U128 :: ZERO ) . into ( ) ;
275
+ let y = U128 :: random ( & mut rng) ;
276
+ ( x, NonZero :: new ( y) . unwrap ( ) )
277
+ } ,
278
+ |( x, y) | black_box ( x. rem ( & y) ) ,
279
+ BatchSize :: SmallInput ,
280
+ )
281
+ } ) ;
282
+
283
+ group. bench_function ( "rem, U256/U128 (in U256)" , |b| {
284
+ b. iter_batched (
285
+ || {
286
+ let x = U256 :: random ( & mut rng) ;
287
+ let y: U256 = U128 :: random ( & mut rng) . resize ( ) ;
288
+ ( x, NonZero :: new ( y) . unwrap ( ) )
289
+ } ,
290
+ |( x, y) | black_box ( x. rem ( & y) ) ,
291
+ BatchSize :: SmallInput ,
292
+ )
293
+ } ) ;
294
+
295
+ group. bench_function ( "rem, U256/U128 (in U512)" , |b| {
296
+ b. iter_batched (
297
+ || {
298
+ let x = U256 :: random ( & mut rng) ;
299
+ let y: U512 = U128 :: random ( & mut rng) . resize ( ) ;
253
300
( x, NonZero :: new ( y) . unwrap ( ) )
254
301
} ,
255
302
|( x, y) | black_box ( x. rem ( & y) ) ,
0 commit comments