@@ -314,4 +314,201 @@ mod xxhash3_64 {
314
314
criterion_group ! ( benches, tiny_data, oneshot, streaming) ;
315
315
}
316
316
317
- criterion_main ! ( xxhash64:: benches, xxhash3_64:: benches) ;
317
+ mod xxhash3_128 {
318
+ use super :: * ;
319
+
320
+ fn tiny_data ( c : & mut Criterion ) {
321
+ let ( seed, data) = gen_data ( 240 ) ;
322
+ let mut g = c. my_benchmark_group ( "xxhash3_128" , "tiny_data" ) ;
323
+
324
+ // let categories = 0..=data.len();
325
+
326
+ // Visual inspection of all the data points showed these as
327
+ // examples of thier nearby neighbors.
328
+ let categories = [
329
+ 0 , 2 , 6 , 13 , 25 , 50 , 80 , 113 , 135 , 150 , 165 , 185 , 200 , 215 , 230 ,
330
+ ] ;
331
+
332
+ for size in categories {
333
+ let data = & data[ ..size] ;
334
+ g. throughput ( Throughput :: Bytes ( data. len ( ) as _ ) ) ;
335
+
336
+ let id = format ! ( "impl-c/size-{size:03}" ) ;
337
+ g. bench_function ( id, |b| {
338
+ b. iter ( || c:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
339
+ } ) ;
340
+
341
+ let id = format ! ( "impl-c-scalar/size-{size:03}" ) ;
342
+ g. bench_function ( id, |b| {
343
+ b. iter ( || c:: scalar:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
344
+ } ) ;
345
+
346
+ #[ cfg( target_arch = "aarch64" ) ]
347
+ {
348
+ let id = format ! ( "impl-c-neon/size-{size:03}" ) ;
349
+ g. bench_function ( id, |b| {
350
+ b. iter ( || c:: neon:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
351
+ } ) ;
352
+ }
353
+
354
+ #[ cfg( target_arch = "x86_64" ) ]
355
+ {
356
+ let id = format ! ( "impl-c-avx2/size-{size:03}" ) ;
357
+ g. bench_function ( id, |b| {
358
+ b. iter ( || c:: avx2:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
359
+ } ) ;
360
+
361
+ let id = format ! ( "impl-c-sse2/size-{size:03}" ) ;
362
+ g. bench_function ( id, |b| {
363
+ b. iter ( || c:: sse2:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
364
+ } ) ;
365
+ }
366
+
367
+ let id = format ! ( "impl-rust/size-{size:03}" ) ;
368
+ g. bench_function ( id, |b| {
369
+ b. iter ( || rust:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
370
+ } ) ;
371
+ }
372
+
373
+ g. finish ( ) ;
374
+ }
375
+
376
+ fn oneshot ( c : & mut Criterion ) {
377
+ let ( seed, data) = gen_data ( BIG_DATA_SIZE ) ;
378
+ let mut g = c. my_benchmark_group ( "xxhash3_128" , "oneshot" ) ;
379
+
380
+ for size in half_sizes ( data. len ( ) ) . take_while ( |& s| s >= MIN_BIG_DATA_SIZE ) {
381
+ let data = & data[ ..size] ;
382
+ g. throughput ( Throughput :: Bytes ( data. len ( ) as _ ) ) ;
383
+
384
+ let id = format ! ( "impl-c/size-{size:07}" ) ;
385
+ g. bench_function ( id, |b| {
386
+ b. iter ( || c:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
387
+ } ) ;
388
+
389
+ let id = format ! ( "impl-c-scalar/size-{size:07}" ) ;
390
+ g. bench_function ( id, |b| {
391
+ b. iter ( || c:: scalar:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
392
+ } ) ;
393
+
394
+ #[ cfg( target_arch = "aarch64" ) ]
395
+ {
396
+ let id = format ! ( "impl-c-neon/size-{size:07}" ) ;
397
+ g. bench_function ( id, |b| {
398
+ b. iter ( || c:: neon:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
399
+ } ) ;
400
+ }
401
+
402
+ #[ cfg( target_arch = "x86_64" ) ]
403
+ {
404
+ let id = format ! ( "impl-c-avx2/size-{size:07}" ) ;
405
+ g. bench_function ( id, |b| {
406
+ b. iter ( || c:: avx2:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
407
+ } ) ;
408
+
409
+ let id = format ! ( "impl-c-sse2/size-{size:07}" ) ;
410
+ g. bench_function ( id, |b| {
411
+ b. iter ( || c:: sse2:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
412
+ } ) ;
413
+ }
414
+
415
+ let id = format ! ( "impl-rust/size-{size:07}" ) ;
416
+ g. bench_function ( id, |b| {
417
+ b. iter ( || rust:: XxHash3_128 :: oneshot_with_seed ( seed, data) )
418
+ } ) ;
419
+ }
420
+
421
+ g. finish ( ) ;
422
+ }
423
+
424
+ fn streaming ( c : & mut Criterion ) {
425
+ let mut g = c. my_benchmark_group ( "xxhash3_128" , "streaming" ) ;
426
+
427
+ let size = 1024 * 1024 ;
428
+ let ( seed, data) = gen_data ( size) ;
429
+
430
+ for chunk_size in half_sizes ( size) {
431
+ let chunks = data. chunks ( chunk_size) . collect :: < Vec < _ > > ( ) ;
432
+
433
+ g. throughput ( Throughput :: Bytes ( size as _ ) ) ;
434
+
435
+ let id = format ! ( "impl-c/size-{size:07}/chunk_size-{chunk_size:07}" ) ;
436
+ g. bench_function ( id, |b| {
437
+ b. iter ( || {
438
+ let mut hasher = c:: XxHash3_128 :: with_seed ( seed) ;
439
+ for chunk in & chunks {
440
+ hasher. write ( chunk) ;
441
+ }
442
+ hasher. finish ( )
443
+ } )
444
+ } ) ;
445
+
446
+ let id = format ! ( "impl-c-scalar/size-{size:07}/chunk_size-{chunk_size:07}" ) ;
447
+ g. bench_function ( id, |b| {
448
+ b. iter ( || {
449
+ let mut hasher = c:: scalar:: XxHash3_128 :: with_seed ( seed) ;
450
+ for chunk in & chunks {
451
+ hasher. write ( chunk) ;
452
+ }
453
+ hasher. finish ( )
454
+ } )
455
+ } ) ;
456
+
457
+ #[ cfg( target_arch = "aarch64" ) ]
458
+ {
459
+ let id = format ! ( "impl-c-neon/size-{size:07}/chunk_size-{chunk_size:07}" ) ;
460
+ g. bench_function ( id, |b| {
461
+ b. iter ( || {
462
+ let mut hasher = c:: neon:: XxHash3_128 :: with_seed ( seed) ;
463
+ for chunk in & chunks {
464
+ hasher. write ( chunk) ;
465
+ }
466
+ hasher. finish ( )
467
+ } )
468
+ } ) ;
469
+ }
470
+
471
+ #[ cfg( target_arch = "x86_64" ) ]
472
+ {
473
+ let id = format ! ( "impl-c-avx2/size-{size:07}/chunk_size-{chunk_size:07}" ) ;
474
+ g. bench_function ( id, |b| {
475
+ b. iter ( || {
476
+ let mut hasher = c:: avx2:: XxHash3_128 :: with_seed ( seed) ;
477
+ for chunk in & chunks {
478
+ hasher. write ( chunk) ;
479
+ }
480
+ hasher. finish ( )
481
+ } )
482
+ } ) ;
483
+
484
+ let id = format ! ( "impl-c-sse2/size-{size:07}/chunk_size-{chunk_size:07}" ) ;
485
+ g. bench_function ( id, |b| {
486
+ b. iter ( || {
487
+ let mut hasher = c:: sse2:: XxHash3_128 :: with_seed ( seed) ;
488
+ for chunk in & chunks {
489
+ hasher. write ( chunk) ;
490
+ }
491
+ hasher. finish ( )
492
+ } )
493
+ } ) ;
494
+ }
495
+
496
+ let id = format ! ( "impl-rust/size-{size:07}/chunk_size-{chunk_size:07}" ) ;
497
+ g. bench_function ( id, |b| {
498
+ b. iter ( || {
499
+ let mut hasher = rust:: XxHash3_128 :: with_seed ( seed) ;
500
+ for chunk in & chunks {
501
+ hasher. write ( chunk) ;
502
+ }
503
+ hasher. finish_128 ( )
504
+ } )
505
+ } ) ;
506
+ }
507
+
508
+ g. finish ( ) ;
509
+ }
510
+
511
+ criterion_group ! ( benches, tiny_data, oneshot, streaming) ;
512
+ }
513
+
514
+ criterion_main ! ( xxhash64:: benches, xxhash3_64:: benches, xxhash3_128:: benches) ;
0 commit comments