File tree 1 file changed +46
-0
lines changed 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -354,3 +354,49 @@ mod test {
354
354
assert_eq ! ( mac. as_slice( ) , expected. as_slice( ) ) ;
355
355
}
356
356
}
357
+
358
+ #[ cfg( test) ]
359
+ mod bench {
360
+ use test:: Bencher ;
361
+ use mac:: Mac ;
362
+ use poly1305:: Poly1305 ;
363
+
364
+ #[ bench]
365
+ pub fn poly1305_10 ( bh : & mut Bencher ) {
366
+ let mut mac = [ 0u8 , ..16 ] ;
367
+ let key = [ 0u8 , ..32 ] ;
368
+ let bytes = [ 1u8 , ..10 ] ;
369
+ bh. iter ( || {
370
+ let mut poly = Poly1305 :: new ( key) ;
371
+ poly. input ( bytes) ;
372
+ poly. raw_result ( mac. as_mut_slice ( ) ) ;
373
+ } ) ;
374
+ bh. bytes = bytes. len ( ) as u64 ;
375
+ }
376
+
377
+ #[ bench]
378
+ pub fn poly1305_1k ( bh : & mut Bencher ) {
379
+ let mut mac = [ 0u8 , ..16 ] ;
380
+ let key = [ 0u8 , ..32 ] ;
381
+ let bytes = [ 1u8 , ..1024 ] ;
382
+ bh. iter ( || {
383
+ let mut poly = Poly1305 :: new ( key) ;
384
+ poly. input ( bytes) ;
385
+ poly. raw_result ( mac. as_mut_slice ( ) ) ;
386
+ } ) ;
387
+ bh. bytes = bytes. len ( ) as u64 ;
388
+ }
389
+
390
+ #[ bench]
391
+ pub fn poly1305_64k ( bh : & mut Bencher ) {
392
+ let mut mac = [ 0u8 , ..16 ] ;
393
+ let key = [ 0u8 , ..32 ] ;
394
+ let bytes = [ 1u8 , ..65536 ] ;
395
+ bh. iter ( || {
396
+ let mut poly = Poly1305 :: new ( key) ;
397
+ poly. input ( bytes) ;
398
+ poly. raw_result ( mac. as_mut_slice ( ) ) ;
399
+ } ) ;
400
+ bh. bytes = bytes. len ( ) as u64 ;
401
+ }
402
+ }
You can’t perform that action at this time.
0 commit comments