concat perf test CORRECT
JavaScript performance comparison
Preparation code
<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,b1).concat(b1);
}
// Make 15 testscases. Each testcase has between 38 arrays of length 0100 which must be combined.
function makeArrays() {
return range(3+randInt(5)).map(function(){return range(randInt(100))})
}
var tests = range(15).map(makeArrays);
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test  Ops/sec  

[].concat.apply([], arrays) 

pending… 
repeated concat with for loop 

pending… 
arrays.reduce(function(a,b){return a.concat(b)}, []) 

pending… 
repeated push(#,#,...,#) with for loop 

pending… 
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit
to the URL. Here’s a list of current revisions for this page:
 Revision 1: published
 Revision 2: published
 Revision 3: published
 Revision 4: published
 Revision 5: published
 Revision 6: published
 Revision 7: published
 Revision 8: published and last updated
 Revision 9: published
 Revision 10: published
 Revision 11: published by Sebastian Markbåge
 Revision 12: published by Naja Melan
 Revision 13: published by blackkbot
 Revision 14: published
 Revision 16: published by Chris
 Revision 17: published by Charlie
 Revision 18: published by Charlie
 Revision 19: published
0 comments
Comment form temporarily disabled.