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
const arr = [
...Array(1000)
].map(e=>~~(Math.random()*1000))
const fArr = Float32Array.from(arr)
const findMinMax = arr => arr.reduce((p, c) => {
p[0] = c < p[0] ? c : p[0] ?? c;
p[1] = c > p[1] ? c : p[1] ?? c;
return p;
}, [undefined, undefined])
const findMinMax2 = arr => {
let min = arr[0];
let max = arr[0];
let i = arr.length;
while (i--) {
min = arr[i] < min ? arr[i] : min;
max = arr[i] > max ? arr[i] : max;
}
return { min, max };
}
Ready to run.
Test | Ops/sec | |
---|---|---|
findMinMax Array |
| ready |
findMinMax Float32Array |
| ready |
Math.min/max Array |
| ready |
Math.min/max Float32Array |
| ready |
findMinMax2 Array |
| ready |
findMinMax2 Float32Array |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.