RNG Benchmarks (v0.2)
Published:
2021-06-07

Some quick benchmarks of the RNG algorithms currently implemented for v0.2.

System Information

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1500 (1909/November2018Update/19H2)
Intel Core i7-9700K CPU 3.60GHz (Coffee Lake), 1 CPU, 8 logical and 8 physical cores
.NET Core SDK=5.0.201
  [Host]          : .NET Core 5.0.4 (CoreCLR 5.0.421.11614, CoreFX 5.0.421.11614), X64 RyuJIT
  .NET Framework  : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
  .NET 5, no AVX2 : .NET Core 5.0.4 (CoreCLR 5.0.421.11614, CoreFX 5.0.421.11614), X64 RyuJIT
  .NET 5          : .NET Core 5.0.4 (CoreCLR 5.0.421.11614, CoreFX 5.0.421.11614), X64 RyuJIT

Results

RngUInt64.NET Framework.NET 5, no AVX2.NET 5
ChaCha8187.30 MB/s970.70 MB/s1,285.57 MB/s
ChaCha12147.38 MB/s775.92 MB/s1,025.21 MB/s
ChaCha20101.88 MB/s550.32 MB/s817.92 MB/s
mt19937-64736.41 MB/s782.77 MB/s829.18 MB/s
PCG321,224.33 MB/s1,412.73 MB/s1,411.52 MB/s
XorShift1,333.21 MB/s1,464.17 MB/s1,411.20 MB/s
CryptoServiceProvider395.25 MB/s763.68 MB/s800.41 MB/s
System.Random218.05 MB/s198.68 MB/s198.34 MB/s
RngUInt32.NET Framework.NET 5, no AVX2.NET 5
ChaCha8224.02 MB/s978.46 MB/s1,245.75 MB/s
ChaCha12168.06 MB/s780.89 MB/s1,046.13 MB/s
ChaCha20111.17 MB/s555.50 MB/s798.83 MB/s
mt19937-64340.66 MB/s332.02 MB/s345.08 MB/s
PCG322,312.50 MB/s2,411.55 MB/s2,401.94 MB/s
XorShift2,280.48 MB/s2,509.52 MB/s2,511.10 MB/s
CryptoServiceProvider626.10 MB/s706.68 MB/s716.98 MB/s
System.Random216.27 MB/s192.77 MB/s196.86 MB/s
RngFill.NET Framework.NET 5, no AVX2.NET 5
ChaCha8260.09 MB/s1,780.26 MB/s2,850.54 MB/s
ChaCha12183.75 MB/s1,210.77 MB/s1,991.67 MB/s
ChaCha20118.57 MB/s740.51 MB/s1,257.29 MB/s
mt19937-64519.36 MB/s694.89 MB/s696.68 MB/s
PCG32716.96 MB/s1,067.74 MB/s1,129.33 MB/s
XorShift727.54 MB/s1,101.26 MB/s1,163.73 MB/s
CryptoServiceProvider1,652.05 MB/s2,310.89* MB/s2,291.79 MB/s
System.Random175.45 MB/s132.04 MB/s137.85 MB/s

* Since CryptoServiceProvider relies on an external CSPRNG, disabling AVX2 for .NET likely has no effect.