array.join vs array.tostring

JavaScript performance comparison

Revision 3 of this test case created by David Bonnet

Preparation code

<script>
  var arr = ["a", "b", "c", "d"];
  var big = ["a", "b", "c", "d"];
  var i=5;
  while (i-- > 0) {
    big = big.concat(big);
  }
</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
array.join
var r = arr.join(',');
pending…
array.toString
var r = arr.toString();
pending…
array.join big
var r = big.join(',');
pending…
array.toString big
var r = big.toString();
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