slow /dev/urandom

Something that always bugged me, was the speed of the /dev/urandom device, which provides random data. I needed it to benchmark some network devices and urandom just wasn't fast enough for that :-D
Anyway, openssl provides also a way to generate some random data, which is much faster (\~4 times faster!) than the original urandom.

So here quickly to proove;
A standard /dev/urandom delivers \~9MB/s.

|| user@workstation ~ ||  time dd if=/dev/urandom of=/dev/null count=100 bs=1M
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 11.7687 s, 8.9 MB/s

real    0m11.770s
user    0m0.000s
sys     0m11.765s

Whereas the openssl variant provides \~39MB/s.

|| user@workstation ~ ||  time openssl rand $[1024*1024*100] | dd of=/dev/null
204800+0 records in
204800+0 records out
104857600 bytes (105 MB) copied, 2.69224 s, 38.9 MB/s

real    0m2.694s
user    0m2.576s
sys     0m0.152s

Notes

  • Test has been made with a 'AMD Phenom(tm) II X6 1090T Processor (6x 3.2GHz)'
  • Test OS was a Debian. I've also made this comparison under Cygwin, and there it's the other way round, so /dev/urandom is faster!

Cheers,
Raphi