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
// Accepted Answer
function multiplyMatricesA1(m1, m2) {
var result = [];
for (var i = 0; i < m1.length; i++) {
result[i] = [];
for (var j = 0; j < m2[0].length; j++) {
var sum = 0;
for (var k = 0; k < m1[0].length; k++) {
sum += m1[i][k] * m2[k][j];
}
result[i][j] = sum;
}
}
return result;
}
// Fernando Carvajal's answer
function multiplyMatricesA2(A, B) {
var result = new Array(A.length).fill(0).map(row => new Array(B[0].length).fill(0));
return result.map((row, i) => {
return row.map((val, j) => {
return A[i].reduce((sum, elm, k) => sum + (elm*B[k][j]) ,0)
})
})
}
const bigVector = new Array(512).fill(null).map((_, i)=>i);
const bigMatrix = new Array(512).fill(null).map(()=>bigVector.slice(0));
Ready to run.
Test | Ops/sec | |
---|---|---|
Accepted Answer |
| ready |
Fernando Carvajal's answer |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.