PRNG comparison

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

<script src="https://raw.github.com/gist/1342599/cd146576d84133ef260dca195804865e37da90ba/alea.js"></script>
<script src="https://raw.github.com/gist/1342599/76b04861a56ad22b076cf39a12fe4c91614615d7/kiss07.js"></script>
<script src="https://raw.github.com/gist/1342599/b832b0e522e72de0a932e2f4567e31336ceeec84/kybos.js"></script>
<script src="https://raw.github.com/gist/1342599/b3997929765c9f8bca5281bc0d32a753b2738eb5/lfib.js"></script>
<script src="https://raw.github.com/gist/1342599/a4a5a532601ad511a9841ab0ec60448dae4fd7c1/lfib4.js"></script>
<script src="https://raw.github.com/gist/1342599/5c6667bb9aca9228836eae19d0684647bbdc65c5/mash.js"></script>
<script src="https://raw.github.com/gist/1342599/f104ec805a7a1221fff055e6b7daaa452f86eda6/mrg32k3a.js"></script>
<script src="https://raw.github.com/gist/1342599/3a54bf50924a53154f99370e343feeddad2b601b/xorshift03.js"></script>

<script src="https://raw.github.com/chr15m/jsGameSoup/master/js/random.js"></script>

<script src="https://raw.github.com/gist/300494/f003af3e59a164330da573202f2372b94eb8ae47/mersenne-twister.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var seed = +new Date(),
    aleaGen = Alea(seed),
    kiss07Gen = KISS07(seed),
    kybosGen = Kybos(seed),
    lfibGen = LFib(seed),
    lfib4Gen = LFIB4(seed),
    mrg32k3aGen = MRG32k3a(seed),
    xorshift3Gen = Xorshift03(seed),
    seedableRandomGen = new SeedableRandom(),
    mersenneTwisterGen = new MersenneTwister()
   
   
    seedableRandomGen.seed(seed);
    var x = 0;
   
};

Benchmark.prototype.teardown = function() {
    window.x = x;
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
alea
x += aleaGen();
pending…
KISS07
x += kiss07Gen()
pending…
Kybos
x += kybosGen()
pending…
LFib
x += lfibGen()
pending…
LFIB4
x += lfib4Gen()
pending…
MRG32k3a
x += mrg32k3aGen()
pending…
Xorshift3
x += xorshift3Gen()
pending…
SeedableRandom
x += seedableRandomGen.next()
pending…
MersenneTwister
x += mersenneTwisterGen.random()
pending…
Math.random()
x += Math.random()
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment