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 = [], sparse2 = [], sparse3 = [],
full = [],
full2 = [];
N = 32;//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") {
sparse2[i] = sparse[i];
sparse3[i] = sparse[i];
full[i] = sparse[i];
full2[i] = sparse[i];
} else {
sparse2[i] = undefined;
sparse3[i] = null;
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 |
| for loop over sparse | | ready |
| for loop over faux-sparse | | ready |
| for loop over faux-sparse (null) | | ready |
| loop over full (with 0 check) | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.