Random Number Generator Performance

A good random number generator ought to be efficient, by which we mean it should be fast, be no larger than necessary, and be implementable with only a small amount of code.

Speed

figures/Microbench-Annotated.png

Benchmark performance contrasting PCG generators against widely used generators.

The graph above shows benchmark performance contrasting PCG generators against several widely used generators—higher Gb/s is better. All members of the PCG family are faster than other generators in their class. RanQ1, the Mersenne Twister, and Minstd are all colored red because they fail statistical tests. Arc4Random and XorShift* 64/32 pass the TestU01 statistical test suite but also have minor statistical issues.

(This graph uses Arc4Random to represent cryptographically secure generators. ChaCha20 is a more recent cryptographically secure generator adopted by OpenBSD, but even though ChaCha20 is much faster than Arc4 in its intended application as a stream cipher, it is only 70% faster than arc4random when used as a RNG; if we swapped in ChaCha20 for Arc4Random, it would still be the slowest.)

You can much more details about the time performance of these generators in the PCG paper and in the section of the website contrasting other random number generators.

But the short version is that the PCG family includes generators that are really fast.

Space

You can find details about this topic both in the PCG paper and in the section of the website contrasting other random number generators.

But the short version is that the PCG family includes generators that are very space efficient.

Code Size

Code size matters too. This issue is discussed on its own page.

But the short version is that generators in the PCG family can use a tiny amount of code.