The built-in pseudo-random number generator in .NET, System.Random
, is suitable for a wide range of applications. It offers a reasonable speed and a very reasonable level of randomness. But if you need a lot of random numbers, and aren't too worried about their quality, you might go looking for an alternative.
One such alternative is a family of algorithms discovered by George Marsaglia, collectively called Xorshift. Xorshift is fast, has a period of around 2128 and passes Marsaglia's Diehard tests of randomness, provided the initial state is good.
But just how much faster is it than System.Random
, given a C# implementation? Let's find out!