Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 2.05 KB

README.md

File metadata and controls

43 lines (29 loc) · 2.05 KB

GitHub Workflow Status GitHub Downloads
NuGet

Fast.PRNGs.NET

Experiment - fast PRNG implementations in .NET. Your PRNG is unlikely to be a bottleneck in anything you do, but there are exceptions like for instance Monte Carlo simulations, where generating random samples can take some time.

To be clear - there is little original work here, only .NET implementations of existing algorithms. Mainly for learning/curiosity purposes.

Sources:

Benchmarks

The benchmarks measure generation of doubles. Iterations = doubles per op.

There is likely overhead in capturing hardware counters, so these should be more "correct"

Scaling iterations

Design

  • Zero allocations (vectorized PRNGs may allocate during constructions since they may be buffered, see Shishua)
  • Implemented as structs - cache locality
  • Inline as much as possible - no virtual calls/indirection (and if something isn't inlined, the above also helps)
  • No abstraction - interfaces etc, makes it easier to not invalidate the above
  • Vectorization where possible - beneficial if PRNG is on your hotpath

Running tests

dotnet test -c Release --logger:"console;verbosity=detailed"

Plotly diagrams are generated during tests where distritution is compared to System.Random as a baseline. The goal is for the implemented PRNGs to match the (uniform) distribution of System.Random.