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

Does the fact that this method accept a list of arguments instead of array affects its performance?

```
const fill = (N) => {
const n = 0.01 * N,
nN = N - n,
MN = 1000,
kM = MN/N,
km = nN*MN/N/N;
return [...new Array(N)]
.map((_, i) => i)
.map(i => [i*kM, i*km])
.map(([M, m]) => m+Math.random(M-m));
}
const data = fill(100000);
const max2MathMax = (a, b) => Math.max(a,b);
const max2Tern = (a, b) => a > b ? a : b;
function myReduce(arr, f) {
let acc = f(arr[0], arr[1]);
for (let i = 1; i < arr.length; i++) {
acc = f(acc, arr[i]);
}
return acc;
}
```

Ready to run.

Test | Ops/sec | |
---|---|---|

Math.max |
| ready |

reduce + ternary |
| ready |

for + ternary |
| ready |

reduce + Math.max |
| ready |

for + Math.max |
| ready |

my reduce + ternary |
| ready |

You can edit these tests or add more tests to this page by appending /edit to the URL.

- Revision 1: published on
- Revision 2: published on