Combining JS Arrays

JavaScript performance comparison

Revision 13 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
  var b = [ "foo", "bar", "baz", "bam", "bun", "fun" ];
  
  function combineInto(a,b) {
      var len = a.length;
      for (var i=0; i < len; i=i+5000) {
          b.unshift.apply( b, a.slice( i, i+5000 ) );
      }
  }

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
looped push
while (b.length) {
  a.push(b.shift());
}
pending…

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments