array join vs string connect

JavaScript performance comparison

Revision 46 of this test case created

Preparation code

<script>
  var blah = "Test Test";
</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 tmp = [];
for (i = 0; i < 100; i++) {
  tmp.push(blah + "This is a test of a really long string to see if there is any difference based on the size of data being concatenated vs pushed into an array.  Hopefully, concatenate wins because I really don't like the look of the array push, seems misleading since the output itself is going to be a string (always) and never has anything to do with an array." + blah + "This is a test of a really long string to see if there is any difference based on the size of data being concatenated vs pushed into an array.  Hopefully, concatenate wins because I really don't like the look of the array push, seems misleading since the output itself is going to be a string (always) and never has anything to do with an array. " + blah);
}
var output = tmp.join('');
pending…
string connect
var output = '';
for (i = 0; i < 100; i++) {
  output += blah + "This is a test of a really long string to see if there is any difference based on the size of data being concatenated vs pushed into an array.  Hopefully, concatenate wins because I really don't like the look of the array push, seems misleading since the output itself is going to be a string (always) and never has anything to do with an array." + blah + "This is a test of a really long string to see if there is any difference based on the size of data being concatenated vs pushed into an array.  Hopefully, concatenate wins because I really don't like the look of the array push, seems misleading since the output itself is going to be a string (always) and never has anything to do with an array. " + blah;
}
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