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
var n, N, i, I, sparse = [],
full = [],
full2 = [];
N = 16384;
I = 8;
for (i = 0; i < I; i++) {
do {
n = (N * Math.random()) | 0;
if (n > (N - 1)) {
n = N - 1;
}
} while (sparse[n]);
sparse[n] = -100 + 200 * Math.random();
}
full.length = N;
full2.length = N;
for (i = 0; i < N; i++) {
if (typeof sparse[i] === "number") {
full[i] = sparse[i];
full2[i] = sparse[i];
} else {
full[i] = 0;
full2[i] = -100 + 200 * Math.random();
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Sparse array sum |
| ready |
Full array sum |
| ready |
Running sparse on full array |
| ready |
Sum all elements on a full array without zeros |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.