I have done it again; I have made another pseudo-random number generator package with all the bells and whistles, but this time in Rust. I named it SmolPRNG as an homage to the original SmallPRNG written in C++. This new package is blazing fast and fully featured, with over 20 different generator algorithms and 15 statistical distributions that can be sampled. A new algorithm can be included and hooked into the front end with only the definition of the generator and two macros that are already defined, so in that way, it is extensible, just like SmallPRNG. To live up to the Smol
name, this package with all unit tests and benchmarks comes in at just over 1000 lines of code which is quite small given the feature set of the library. SmolPRNG was mostly a learning project, but I hope that this can be used for useful applications like SmallPRNG was. Please go and check it out on crate.io!
Did I mention that this is FAST? These are the benchmark numbers for a 12700K running at stock settings. The typical generators run double-digit gigabytes per second, and random floating-point numbers can be generated in less than a nanosecond!
Generating 1024 byte Buffer
Time | Bandwidth | |
---|---|---|
Step Generator | 49ns | 20.4 GB/s |
Xoshiro256+ | 87ns | 11.5 GB/s |
SplitMix64 | 92ns | 10.9 GB/s |
JSFLarge | 105ns | 9.5 GB/s |
Summing 1 million randomly generated f64
Time | Time per f64 | |
---|---|---|
Step Generator | 0.32 ms | 0.32 ns |
Xoshiro256+ | 0.62 ms | 0.62 ns |
SplitMix64 | 0.63 ms | 0.63 ns |
JSFLarge | 0.79 ms | 0.79 ns |