array concat arguments

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    arr = [1,2,3,4,5];
    arg = {0:'aa', 1:'bb', 2:'cc', length:3};
    slice = Array.prototype.slice;
    concat = Array.prototype.concat;
    i = 0;
    j = arg.length;
};

Benchmark.prototype.teardown = function() {
    arr = [1,2,3,4,5];
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
slice
arr.concat( slice.call( arg ) );
pending…
concat
arr.concat( concat.call( arg ) );
pending…
code
i = 0;
while( i < j ) arr[arr.length] = arg[i++];
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:

0 comments

Add a comment