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
from end to 0.
var myArray = ['a', 'b', 'c', 'd','f','e','g','h','i','j','k','l','m'];
function fn1() {
var tmp = [],
i;
for (i = myArray.length; i+1; i--) {
tmp[i] = myArray[i];
}
return tmp.join('');
}
function fn2() {
var tmp = [],
i;
for (i = 0; i<myArray.length; i++) {
tmp[tmp.length] = myArray[i];
}
return tmp.join('');
}
function fn3() {
var output = '',
i;
for (i = 0; i<myArray.length; i++) {
output += myArray[i];
}
return output;
}
function fn4() {
var tmp = [],
i,
il;
for (i = 0, il = myArray.length; i<il; i++) {
tmp[tmp.length] = myArray[i];
}
return tmp.join('');
}
function fn5() {
var output = '',
i,
il;
for (i = 0, il = myArray.length; i < il; i++) {
output += myArray[i];
}
return output;
}
function fn6() {
var tmp = [],
i;
for (i = myArray.length - 1; i+1; i--) {
tmp.push(myArray[i]);
}
return tmp.join('');
}
Ready to run.
Test | Ops/sec | |
---|---|---|
array join (use push) |
| ready |
array join (use length) |
| ready |
string concat |
| ready |
array join (use length) - optimized |
| ready |
string concat - optimized |
| ready |
array join (use push) - optimized |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.