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
native vs 3 loops vs. 1 loop.
var n = 10000,
arr = new Array(n)
drop = 0.1 // Proportion of numbers to drop
;
// Deterministic pseudo-random numbers to make sure
// arr is always generated the same way.
// http://stackoverflow.com/questions/521295/javascript-random-seeds
var seed = 1;
function random() {
var x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}
for (var i = n; i--;)
arr[i] = {
p: random() < drop ? null : i
};
Ready to run.
Test | Ops/sec | |
---|---|---|
3 loops |
| ready |
1 loop |
| ready |
native |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.