digitalmars.D - RND engines benchs
- bearophile (21/21) Feb 18 2011 Timings, n = 100_000_000, seconds, best of 6:
- %u (13/34) Feb 18 2011 What do you think of my 2 sided dice?
Timings, n = 100_000_000, seconds, best of 6: Xorshift: 1.08 MinstdRand: 1.15 Mt19937: 1.92 DMD 2.052. It seems that compared to MinstdRand, Xorshift is both faster and gives higher quality outputs :-) import std.stdio, std.random; void main() { uint r; //auto rnd = Xorshift(1); //auto rnd = Mt19937(1); auto rnd = MinstdRand(1); foreach (i; 0 .. 100_000_000) { r = rnd.front; rnd.popFront(); } writeln(r); } Another interesting engine: http://d.puremagic.com/issues/show_bug.cgi?id=5509 Bye, bearophile
Feb 18 2011
== Quote from bearophile (bearophileHUGS lycos.com)'s articleTimings, n = 100_000_000, seconds, best of 6: Xorshift: 1.08 MinstdRand: 1.15 Mt19937: 1.92 DMD 2.052. It seems that compared to MinstdRand, Xorshift is both faster andgives higher quality outputs :-)import std.stdio, std.random; void main() { uint r; //auto rnd = Xorshift(1); //auto rnd = Mt19937(1); auto rnd = MinstdRand(1); foreach (i; 0 .. 100_000_000) { r = rnd.front; rnd.popFront(); } writeln(r); } Another interesting engine: http://d.puremagic.com/issues/show_bug.cgi?id=5509 Bye, bearophileWhat do you think of my 2 sided dice? bool randBool() { static uint r; static size_t n = 32; if( n >= 32 ){ r = rand(); n = 0; } return cast(bool)bt( &r, n++ ); }
Feb 18 2011