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
<script>
function randInt(n) {
// return random int in range [0,n)
return Math.floor(Math.random()*n)
}
function range(a,b) {
// > range(2,5)
// [2, 3, 4]
if (b===undefined) {
b=a; a=0;
}
return a==b ? [] : range(a,b-1).concat(b-1);
}
// Make 4 testscases of arrays which must be combined.
function makeArrays(i) {
return [
range(2,3).map(function(){return range(80,90)}),
range(8,10).map(function(){return range(50,80)}),
range(40,45).map(function(){return range(0,80)}),
range(1000,1100).map(function(){return range(0,5)})
];
}
var tests = range(3).map(makeArrays);
realResults = tests.map(function(arrays){return [].concat.apply([], arrays)});
</script>
if (JSON.stringify(results) != JSON.stringify(realResults)) {
console.log('got: ', results, 'expected: ', realResults);
throw "This test case "+this+" returns the wrong results. See console."
}
Ready to run.
Test | Ops/sec | |
---|---|---|
[].concat.apply([], arrays) |
| ready |
repeated concat with for loop |
| ready |
arrays.reduce(function(a,b){return a.concat(b)}, []) |
| ready |
push each array one-by-one: push(#,#,...,#), push(#,#,...,#), ... |
| ready |
push each element one-by-one: push(#), push(#), ... |
| ready |
foreach |
| ready |
[].concat(result,array) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.