jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Tests to compare performance of various methods to generate random numbers according to a Normal Distribution.
function randBoxMuller() {
var u, v, a, b, x, y;
u = Math.random();
v = Math.random();
a = Math.sqrt(-2 * Math.log(u));
b = 2 * Math.PI * v;
x = a * Math.cos(b);
y = a * Math.sin(b);
return [x, y];
}
function randMarsaglia() {
var u, v, s, a, x, y;
do {
s = u * u + v * v;
} while (s >= 1)
a = Math.sqrt(-2 * Math.log(s) / s);
x = u * a;
y = u * a;
return [x, y];
}
function randApproximation() {
var x, y;
x = (Math.random() + Math.random() + Math.random() + Math.random() + Math.random() + Math.random()) / 6;
y = (Math.random() + Math.random() + Math.random() + Math.random() + Math.random() + Math.random()) / 6;
return [x, y]
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Box-Muller Method |
| ready |
Marsaglia Polar Method |
| ready |
Approximation Method |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.