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:
Revision 12 of this benchmark created by Michael Paulson on
Preparation HTML
<script>functionarrayCopy( arr ) {
var ret = newArray(arr.length);
for( var i = 0, len = arr.length; i < len; ++i ) {
ret[i] = arr[i];
}
return ret;
}
functionarrayCopyForloop(arr) {
var ret = newArray(arr.length);
for (var i = 0, len = arr.length; i < len; ret[i] = arr[i++]);
return ret;
}
</script>
Setup
var arr = [1, 2, 3, 4, 5, 6],
res = [];
Teardown
var res = [];
Test runner
Ready to run.
Testing in
Test
Ops/sec
Concat (individual)
res = [].concat(arr[0],arr[1],arr[2],arr[3],arr[4],arr[5]);
ready
Slice
res = arr.slice(0, 7)
ready
while [ ]
var len = 6,
i = -1;
while (i < len) {
res[i] = arr[i];
i++;
}
ready
while push
var len = 5,
i = -1;
while (i < len) {
res.push(arr[i]);
i++
}