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 count = 1e6;
const data = Array.from({length: count}).map(() => Math.random());
const simpleSum = (data) => {
let sum = 0;
for(let i=0; i < data.length; i += 1) {
sum += data[i];
}
return sum;
}
const parallelSumTwoVar = (data) => {
let sum1 = 0;
let sum2 = 0;
for(let i=0; i < data.length; i += 2) {
sum1 += data[i];
sum2 += data[i + 1];
}
return sum1 + sum2;
};
const parallelSumOneVar = (data) => {
let sum = 0
for(let i=0; i < data.length; i += 2) {
sum += data[i] + data[i + 1];
}
return sum;
}
const parallelSumQuadTwoVar = (data) => {
let sum1 = 0;
let sum2 = 0;
for(let i=0; i < data.length; i += 4) {
sum1 += data[i] + data[i + 1];
sum2 += data[i + 2] + data[i + 3];
}
return sum1 + sum2;
};
const parallelSumQuadOneVar = (data) => {
let sum = 0
for(let i=0; i < data.length; i += 4) {
sum += data[i]
+ data[i + 1]
+ data[i + 2]
+ data[i + 3];
}
return sum;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Regular |
| ready |
Unrolled 2x2 |
| ready |
Unrolled 2x1 |
| ready |
Unrolled 4x2 |
| ready |
Unrolled 4x1 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.