@@ -7,6 +7,7 @@ use std::mem::MaybeUninit;
7
7
// The buffer is hot, and does not require initialization.
8
8
#[ inline( always) ]
9
9
fn bench_getrandom < const N : usize > ( b : & mut test:: Bencher ) {
10
+ b. bytes = N as u64 ;
10
11
b. iter ( || {
11
12
let mut buf = [ 0u8 ; N ] ;
12
13
getrandom:: getrandom ( & mut buf[ ..] ) . unwrap ( ) ;
@@ -18,6 +19,7 @@ fn bench_getrandom<const N: usize>(b: &mut test::Bencher) {
18
19
// scenario. The buffer is still hot, but requires initialization.
19
20
#[ inline( always) ]
20
21
fn bench_getrandom_uninit < const N : usize > ( b : & mut test:: Bencher ) {
22
+ b. bytes = N as u64 ;
21
23
b. iter ( || {
22
24
// TODO: When the feature `maybe_uninit_as_bytes` is available, use:
23
25
// ```
@@ -48,6 +50,9 @@ macro_rules! bench {
48
50
} ;
49
51
}
50
52
53
+ // 16 bytes (128 bits) is the size of an 128-bit AES key/nonce.
54
+ bench ! ( aes128, 128 / 8 ) ;
55
+
51
56
// 32 bytes (256 bits) is the seed sized used for rand::thread_rng
52
57
// and the `random` value in a ClientHello/ServerHello for TLS.
53
58
// This is also the size of a 256-bit AES/HMAC/P-256/Curve25519 key
@@ -56,3 +61,8 @@ bench!(p256, 256 / 8);
56
61
57
62
// A P-384/HMAC-384 key and/or nonce.
58
63
bench ! ( p384, 384 / 8 ) ;
64
+
65
+ // Initializing larger buffers is not the primary use case of this library, as
66
+ // this should normally be done by a userspace CSPRNG. However, we have a test
67
+ // here to see the effects of a lower (amortized) syscall overhead.
68
+ bench ! ( page, 4096 ) ;
0 commit comments