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 a = {}, b=[], num = 20000, lim = 10000;
for (var i = 0; i < num; i++) {
let v = {0:i, 1:i+1, 2:i+2, 3:i+3, 4:i+4, zz:'x'+i};
a[1000+i] = v;
b.push(v);
}
a[-1000] = {0:'50000', 1:1, 2:2, 3:3, 4:4, zz:'x'};
a.x = {0:50001, 1:1, 2:2, 3:3, 4:4, zz:'y'};
var filter = v => v[0]>lim, max = 500;
function* filterMax(array, cb, count) {
var i = 0;
while (count) {
while (i < array.length && !cb(array[i])) i++;
if (i >= array.length) return;
yield array[i++];
count--;
}
}
function* filterMax2(a, cb, count) {
var c, j, i = 0, len = a.length;
for (c=0; c<count; c++) {
for (j=i; j<len; j++) {
if (cb(a[i])) break;
i++;
}
if (i >= len) return;
yield a[i++];
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
for in |
| ready |
Object.values |
| ready |
reduce |
| ready |
filter* |
| ready |
filter2* |
| ready |
classic |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.