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
function doubleUp$ARRAY(arrayOfNumbers) {
var len = arrayOfNumbers.length;
var result = [];
var i, tmp;
for (i = 0; i < len; ++i) {
tmp = arrayOfNumbers[i];
result.push(tmp, tmp);
}
return result;
}
function doubleUp$CONCAT_SORT(data) {
return data.concat(data).sort();
}
function doubleUp$REDUCE( data ) {
return data.reduce( function(storage, val) { storage.push(val,val); return storage; }, [] );
}
function doubleUp_index_insertion( data ) {
var i = 0;
var l = data.length;
var storage = [];
for ( ; i < l; ++i ) {
storage[ storage.length ] = data[i];
storage[ storage.length ] = data[i];
}
return storage;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
simple approach |
| ready |
concat sort approach |
| ready |
Using array reduce |
| ready |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.