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
There is an error in all of these revision, namely in the push on [i] is missing, so it doesn't return at all the intended result, thereby invalidating the tests.
If you want to compare performance of several methods, please run a test to see if the output of each is as intended before publishing.
FYI: All of the tests below have now been tested now for correct results.
<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 15 testscases. Each testcase has between 3-8 arrays of length 0-100 which must be combined.
function makeArrays() {
return range(3+randInt(5)).map(function(){return range(randInt(10000))})
}
var tests = range(15).map(makeArrays);
</script>
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 |
repeated push(#,#,...,#) with for loop |
| ready |
preallocation |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.