| .cargo | ||
| .vscode | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
| rustfmt.toml | ||
Benchmark of Rust PRNG crates
Simple performance benchmark of pseudorandom generation Rust crates for non-cryptographic purposes such as games.
The goal is not to compare algorithms, but implementations that can be used immediately by a Rust developer.
Inclusion criteria:
- Seedable. Needed for reproducibility.
- Simple to use, either thanks to an obvious API or examples in documentation.
- Works on common targets.
- Usable for generating bytes or groups of bytes.
- Builds on my system.
Warning: If your need has anything to do with security, i.e. generating values seeded by or interacting with potentially untrusted data or that should be secret or not leak information about the seed or correlation between multiple outputs, then you should instead use a CSPRNG.
Results
RUSTFLAGS='-C target-cpu=native' cargo run --release
rustc 1.95.0-nightly (57d2fb136 2026-02-01)
Results on AMD Ryzen 7 5700X: (with AVX2)
Time (s) PRNG
0.06720725 simd_rand::specific::avx2::xoshiro256plusplus::Xoshiro256PlusPlusX4
0.06825219 simd_rand::portable::xoshiro256plusx4::Xoshiro256PlusX4
0.06890218 simd_rand::specific::avx2::xoshiro256plus::Xoshiro256PlusX4
0.069135666 simd_rand::portable::xoshiro256plusplusx4::Xoshiro256PlusPlusX4
0.07073431 simd_rand::portable::xoshiro256plusx8::Xoshiro256PlusX8
0.07283282 simd_rand::portable::xoshiro256plusplusx8::Xoshiro256PlusPlusX8
0.07305191 frand::Rand
0.076635174 fast_rands::RomuDuoJrRand
0.07750931 rand_xoshiro::xoshiro256plus::Xoshiro256Plus
0.0798837 wyhash::v1::traits::WyRng
0.08170648 fast_rands::RomuTrioRand
0.082019165 romu::Rng
0.08613385 simd_rand::specific::avx2::shishua::Shishua<32768>
0.08767373 tinyrand::wyrand::Wyrand
0.08789389 wyhash::final3::traits::WyRng
0.087896034 fastrand::Rng
0.08798213 wyrand::final_v4_2::wyrand::WyRand
0.089724645 rand_xoshiro::xoshiro256starstar::Xoshiro256StarStar
0.090424806 rand_xoshiro::xoroshiro128plus::Xoroshiro128Plus
0.09778529 tiny_prng::pcg::PcgXslRr6432Mcg
0.098746814 rand_xoshiro::xoroshiro128plusplus::Xoroshiro128PlusPlus
0.10192768 rand_xoshiro::xoroshiro128starstar::Xoroshiro128StarStar
0.10222766 fast_rands::Xoshiro256PlusPlusRand
0.1025012 rand_xoshiro::xoshiro256plusplus::Xoshiro256PlusPlus
0.10895407 rand::rngs::small::SmallRng
0.109856725 rand_xoshiro::xoshiro512plus::Xoshiro512Plus
0.1161916 tinyrand::xorshift::Xorshift
0.11952907 shishua::core::ShiShuAState
0.1273132 tiny_prng::pcg::PcgXslRrMcg
0.1313371 tiny_prng::xorshift::Xorshift1024star
0.13799635 tiny_prng::xorshift::Xorshift128
0.1382492 rand_xoshiro::xoshiro512plusplus::Xoshiro512PlusPlus
0.13890779 rand_xoshiro::xoshiro512starstar::Xoshiro512StarStar
0.14007749 rand_xoshiro::splitmix64::SplitMix64
0.14576794 rand_xoshiro::xoshiro128plus::Xoshiro128Plus
0.15051891 fast_rands::Sfc64Rand
0.1522026 tiny_prng::pcg::PcgXslRr
0.15726987 tinyrand::splitmix::SplitMix
0.15869391 prng_mt::mt19937::MT19937_64
0.15959476 rand_xoshiro::xoshiro128starstar::Xoshiro128StarStar
0.1698655 bsd4random::BSD
0.17368329 tiny_prng::xorshift::Xorshift64
0.17383604 rand_xoshiro::xoroshiro64star::Xoroshiro64Star
0.17391294 fast_rands::XorShift64Rand
0.1766414 fast_rands::Lehmer64Rand
0.17737824 tiny_prng::xorshift::Xorshift64star
0.18385774 mcg59::MCG59
0.18856412 rand_xoshiro::xoshiro128plusplus::Xoshiro128PlusPlus
0.20034873 tiny_prng::mt64::Mt19937
0.21738203 rand_xoshiro::xoroshiro64starstar::Xoroshiro64StarStar
0.21857128 aes_prng::AesRng
0.23149101 tiny_prng::pcg::PcgXshRs6432
0.23159662 tiny_prng::pcg::PcgXshRr6432
0.28765705 rand::rngs::std::StdRng
0.29028276 prng_mt::mt19937::MT19937
0.3162913 quad_rand::RandGenerator
0.34691545 tiny_prng::xorshift::Xorshift32
0.34718052 nanorand::rand::wyrand::WyRand
0.3953146 tiny_prng::mt::Mt19937
0.40042716 nanorand::rand::pcg64::Pcg64
0.9632352 nanorand::rand::chacha::ChaCha<8>
1.772863 shishua::rand::ShiShuARng
3.5408454 acorn_prng::Acorn
3.706891 simplerand::Random
Results on Intel Core i5-7300HQ: (with AVX2)
Time (s) PRNG
0.08826336 frand::Rand
0.0886573 simd_rand::specific::avx2::xoshiro256plusplus::Xoshiro256PlusPlusX4
0.08876129 simd_rand::portable::xoshiro256plusplusx4::Xoshiro256PlusPlusX4
0.089277595 simd_rand::portable::xoshiro256plusx4::Xoshiro256PlusX4
0.09128572 simd_rand::specific::avx2::xoshiro256plus::Xoshiro256PlusX4
0.09481453 simd_rand::portable::xoshiro256plusx8::Xoshiro256PlusX8
0.10730715 fast_rands::RomuDuoJrRand
0.10897806 fast_rands::RomuTrioRand
0.10994133 simd_rand::specific::avx2::shishua::Shishua<32768>
0.11030309 romu::Rng
0.122153305 simd_rand::portable::xoshiro256plusplusx8::Xoshiro256PlusPlusX8
0.12979501 rand_xoshiro::xoshiro256plus::Xoshiro256Plus
0.13618393 rand_xoshiro::xoshiro256starstar::Xoshiro256StarStar
0.14781812 rand_xoshiro::xoroshiro128plus::Xoroshiro128Plus
0.15827414 fast_rands::Xoshiro256PlusPlusRand
0.15854521 rand_xoshiro::xoshiro256plusplus::Xoshiro256PlusPlus
0.1587491 rand::rngs::small::SmallRng
0.16304855 shishua::core::ShiShuAState
0.1643057 rand_xoshiro::xoroshiro128plusplus::Xoroshiro128PlusPlus
0.16563393 tinyrand::wyrand::Wyrand
0.1673208 fastrand::Rng
0.16902256 wyhash::v1::traits::WyRng
0.16907188 wyrand::final_v4_2::wyrand::WyRand
0.16940956 wyhash::final3::traits::WyRng
0.17095926 rand_xoshiro::xoroshiro128starstar::Xoroshiro128StarStar
0.17670166 fast_rands::Sfc64Rand
0.17687643 tinyrand::xorshift::Xorshift
0.18041892 rand_xoshiro::splitmix64::SplitMix64
0.18187234 tiny_prng::xorshift::Xorshift1024star
0.18540086 tiny_prng::pcg::PcgXslRrMcg
0.18792455 tiny_prng::xorshift::Xorshift128
0.19410424 rand_xoshiro::xoshiro512plus::Xoshiro512Plus
0.20391174 fast_rands::Lehmer64Rand
0.2041288 mcg59::MCG59
0.21445897 rand_xoshiro::xoshiro512plusplus::Xoshiro512PlusPlus
0.21997462 tinyrand::splitmix::SplitMix
0.22679603 rand_xoshiro::xoshiro512starstar::Xoshiro512StarStar
0.23136179 bsd4random::BSD
0.23638329 fast_rands::XorShift64Rand
0.23744445 tiny_prng::pcg::PcgXslRr
0.23768099 tiny_prng::xorshift::Xorshift64star
0.23874637 tiny_prng::xorshift::Xorshift64
0.2519162 tiny_prng::pcg::PcgXslRr6432Mcg
0.2522125 rand_xoshiro::xoshiro128plus::Xoshiro128Plus
0.26618654 rand_xoshiro::xoshiro128starstar::Xoshiro128StarStar
0.31676543 rand_xoshiro::xoshiro128plusplus::Xoshiro128PlusPlus
0.32150853 tiny_prng::pcg::PcgXshRs6432
0.3222107 prng_mt::mt19937::MT19937_64
0.3227826 aes_prng::AesRng
0.32352522 rand_xoshiro::xoroshiro64star::Xoroshiro64Star
0.3316228 tiny_prng::pcg::PcgXshRr6432
0.3506137 rand_xoshiro::xoroshiro64starstar::Xoroshiro64StarStar
0.42379355 nanorand::rand::wyrand::WyRand
0.42504936 quad_rand::RandGenerator
0.46230927 rand::rngs::std::StdRng
0.4671986 tiny_prng::xorshift::Xorshift32
0.5528513 tiny_prng::mt64::Mt19937
0.6312231 prng_mt::mt19937::MT19937
0.6692442 nanorand::rand::pcg64::Pcg64
1.2569348 nanorand::rand::chacha::ChaCha<8>
1.4407393 tiny_prng::mt::Mt19937
2.0606635 shishua::rand::ShiShuARng
3.7855747 acorn_prng::Acorn
15.568359 simplerand::Random
FRand is among the fastest, however it has no particular mathematical justification beyond the fact its parameters were found empirically to minimize bias.
simd_rand provides the fastest implementations of common PRNGs, both portable and SIMD-specific.
fast_rands implements RomuDuoJr, the fastest after simd_rand. It is part of the Romu family which has been studied. It provides good quality up to at least 2^48 bytes. However this crate has too many dependencies that should not be necessary if you only want a PRNG, so copying the wanted functions can be an option.
Surprisingly, the AES PRNG is quite fast, probably due to the AES instruction set.
Also to my surprise, Shishua was slower than RomuTrio, contrarily to the author's claim. Maybe that's the implementation's fault or my lack of AVX512, I should investigate. The streaming overhead can be significant, as we see with ShiShuARng which is very slow compared to the bare ShiShuAState. simd_rand's implementation is quite faster.