Fast random number generation
mouse 978 · person cloud · link
Last update
2017-08-17
2017
08-17
« — »

Here is some empirical data from my notebook, the last command is the fastest:

1
2
3
4
5
6
7
8
9
10
# ~40MB/s | OpenSSL rand
openssl rand 1000000000 | pv > /dev/null

# ~175MB/s | /dev/urandom
pv < /dev/urandom > /dev/null

# ~1200MB/s | OpenSSL enc /dev/zero
openssl enc -aes-256-ctr -nosalt \
  -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" \
   < /dev/zero | pv > /dev/null

Source: OpenSSL rand, OpenSSL enc /dev/zero