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
fill matrix with zeros
function makeZeroMatrix(width, height) {
let matrix = [];
for (let x = 0; x < height; x++) {
matrix[x] = [];
for (let y = 0; y < width; y++) {
matrix[x][y] = 0;
}
}
return matrix;
}
function makeZeroMatrixAlloc(width, height) {
let matrix = new Array(height);
for (let x = 0; x < height; x++) {
matrix[x] = new Array(width);
for (let y = 0; y < width; y++) {
matrix[x][y] = 0;
}
}
return matrix;
}
function makeZeroMatrixFunc(width, height) {
return new Array(height).fill(0).map(_row => new Array(width).fill(0));
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Simple |
| ready |
Preallocated Arrays |
| ready |
Fill and Map |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.