PRNG comparison
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
alea |
|
pending… |
KISS07 |
|
pending… |
Kybos |
|
pending… |
LFib |
|
pending… |
LFIB4 |
|
pending… |
MRG32k3a |
|
pending… |
Xorshift3 |
|
pending… |
SeedableRandom |
|
pending… |
MersenneTwister |
|
pending… |
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:
- Revision 1: published by Andrew Petersen
- Revision 2: published
- Revision 3: published
0 comments