Skip to content

Latest commit

 

History

History
95 lines (85 loc) · 13.1 KB

File metadata and controls

95 lines (85 loc) · 13.1 KB

Random Number Generator Performance Benchmarks

Auto-generated via RandomPerformanceTests.Benchmark. Run the test to refresh these summary and detail tables.

State repair for a generator restored from JSON or protobuf happens in its constructor or the shared after-deserialization callback. This includes each generator's state, the shared bit/byte reservoirs and GUID scratch buffer. Repair is not repeated in a draw method, so malformed/default serialized state is repaired before the first draw without adding a guard to every later draw. PhotonSpin's one-time warmup priming also happens there, leaving only its block-boundary check in the draw path.

For statistical batteries, the repository's Generator~/WallstopStudios.UnityHelpers.RandomQuality host emits a reproducible little-endian byte stream from an explicit generator, GUID seed and byte count. Long PractRand/TestU01 runs belong in scheduled reporting with pinned tools and expected weak-generator failures; they are not suitable as nondeterministic pull-request gates.

Summary (fastest first)

Random NextUint (ops/s) Speed Quality Notes
LinearCongruentialGenerator1,323,700,000FastestPoorNumerical Recipes 'quick and dirty' LCG (a=1664525, c=1013904223, m=2^32) returning the raw state, so bit k has period only 2^(k+1) -- measured linear complexity of bit k is 2^k+1, and bit 0 simply alternates. Cosmetic use only.
WaveSplatRandom1,283,400,000FastestExperimentalSingle-word chaotic generator; author notes period 2^64 but provides no formal test results—treat as experimental.
BlastCircuitRandom1,054,900,000Very FastGoodChaotic ARX mixer rather than a proven statistically optimal generator. Verified here: PractRand 0.95 clean through 8GB, the depth at which SystemRandom fails.
SplitMix641,052,300,000Very FastVery GoodWell-known SplitMix64 mixer; passes TestU01 BigCrush and PractRand up to large data sizes in literature. Vigna 2014
FlurryBurstRandom923,200,000FastExcellentSix-word ARX-style generator tuned for all-around use. Verified here: PractRand 0.95 clean through 8GB, the depth at which SystemRandom fails. The author reports TestU01 BigCrush passes; that run cannot be checked -- the upstream repository is offline.
PcgRandom897,900,000FastExcellentPCG XSH RR 64/32 variant; passes TestU01 BigCrush and PractRand in published results. O'Neill 2014
XoroShiroRandom754,700,000FastFairxoroshiro128+, returning the low 32 bits -- the half its authors document as linear. Measured: bit 0 has linear complexity exactly 128, so NextBool is predictable from 128 draws. Prefer Xoshiro128StarStar or PcgRandom where single bits matter. Blackman & Vigna 2018
IllusionFlow754,500,000FastExcellentFive-word rotate/xor/add generator driven by a 32-bit Weyl counter, and the generator PRNG.Instance returns. Verified here: PractRand 0.95 clean through 8GB, the depth at which SystemRandom fails. The author reports 64GB; that run cannot be checked -- the upstream repository is offline.
RomuDuo750,100,000FastGoodROMU multiplier with a modified duo update; returns the low 32 bits of the 64-bit product. Not the published romuDuo or romuDuoJr, so their measured results do not transfer. Overton 2020
StormDropRandom705,200,000ModerateExcellentLarge-state ARX generator over a 1024-word (4 KB) ring buffer with two 32-bit control words. Verified here: PractRand 0.95 clean through 8GB, the depth at which SystemRandom fails. The author's own results cannot be checked -- the upstream repository is offline.
XorShiftRandom602,100,000ModerateFairClassic 32-bit xorshift; known to fail portions of TestU01 and PractRand, acceptable for lightweight effects only. Marsaglia 2003
WyRandom440,500,000SlowVery GoodWyhash-based generator; published testing shows it clears BigCrush/PractRand with wide seed coverage. Wang Yi 2019
SquirrelRandom414,000,000SlowFairHash-based generator built on Squirrel3. Measured: fails PractRand 0.95 FPF-14+6/16 at 1GB, reproducibly across four seeds. Good equidistribution for the table lookups it was designed for; not a general-purpose stream. Squirrel Eiserloh
PhotonSpinRandom261,100,000Very SlowExcellentSHISHUA-inspired generator. Verified here: PractRand 0.95 clean through 8GB, the depth at which SystemRandom fails. The author reports 128GB; that run cannot be checked -- the upstream repository is offline.
UnityRandom87,600,000Very SlowFairMirrors UnityEngine.Random, documented by Unity as Xorshift 128; suitable for legacy compatibility but not high-stakes simulation. UnityEngine.Random
SystemRandom64,700,000Very SlowPoorReimplements the classic .NET System.Random algorithm (Knuth subtractive lagged-Fibonacci, mod 2^31-1) so its sequence is serializable and stable across runtimes. Fails modern statistical batteries. System.Random considered harmful
DotNetRandom55,900,000Very SlowPoorWraps System.Random, which on Mono and for seeded .NET Core is Knuth's subtractive lagged-Fibonacci generator (mod 2^31-1), not an LCG. The sequence is runtime-dependent, so do not rely on it for cross-platform determinism. System.Random considered harmful

Detailed Metrics

Random NextBool Next NextUint NextFloat NextDouble NextUint (Range) NextInt (Range)
LinearCongruentialGenerator785,200,000538,800,0001,323,700,000184,300,000296,300,000582,900,000498,700,000
WaveSplatRandom787,300,000528,500,0001,283,400,000184,300,000297,900,000529,000,000458,200,000
BlastCircuitRandom788,200,000537,400,0001,054,900,000183,800,000293,200,000479,700,000421,200,000
SplitMix64795,900,000537,200,0001,052,300,000184,400,000297,700,000482,500,000439,100,000
FlurryBurstRandom767,800,000526,500,000923,200,000182,300,000293,100,000449,800,000404,100,000
PcgRandom249,800,000527,300,000897,900,000181,000,000274,700,000447,700,000405,000,000
XoroShiroRandom761,000,000359,000,000754,700,000157,900,000192,400,000422,100,000376,900,000
IllusionFlow779,300,000529,200,000754,500,000183,000,000281,600,000439,200,000390,000,000
RomuDuo784,600,000359,400,000750,100,000156,100,000188,700,000437,700,000384,600,000
StormDropRandom776,600,000523,600,000705,200,000180,600,000252,400,000393,500,000356,700,000
XorShiftRandom783,300,000534,100,000602,100,000184,100,000283,200,000474,500,000383,500,000
WyRandom749,500,000363,000,000440,500,000159,000,000185,300,000290,000,000277,800,000
SquirrelRandom756,300,000382,700,000414,000,000158,800,000197,800,000355,500,000309,500,000
PhotonSpinRandom713,300,000220,800,000261,100,000119,900,000115,800,000217,600,000214,200,000
UnityRandom628,900,00076,700,00087,600,00059,700,00038,800,00081,800,00081,900,000
SystemRandom146,200,000145,700,00064,700,000131,300,000138,600,00058,700,00057,800,000
DotNetRandom544,600,00053,100,00055,900,00044,700,00026,700,00053,400,00051,700,000

Generators added since the last benchmark run

The tables above are rewritten only by a benchmark run, so a generator added since the last one is absent until the .github/workflows/unity-benchmarks.yml workflow next runs. Absence here says nothing about quality: statistical standing is measured separately, by the bit-plane linearity gate on every pull request and by the scheduled PractRand battery. See Random Generators for the current ratings.