RND engines benchs

bearophile bearophileHUGS at lycos.com
Fri Feb 18 09:55:00 PST 2011


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


More information about the Digitalmars-d mailing list