Larger N String Concat

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var str0, str1, str2, str3, str4, str5, str6, str7, str8, str9, str, res;
    str = ["String 1|", "Str 2|", "String Three|", "String Four|", "Str Five|", "STR!NG VI|", "STR VII|", "$trIng ATE|", "word 9|", "JOIN togeather to make this example"];
    str0 = str[0];
    str1 = str[1];
    str2 = str[2];
    str3 = str[3];
    str4 = str[4];
    str5 = str[5];
    str6 = str[6];
    str7 = str[7];
    str8 = str[8];
    str9 = str[9];
};
</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
Plus Var
res = str0 + str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + str9;
pending…
Plus Array
res = str[0] + str[1] + str[2] + str[3] + str[4] + str[5] + str[6] + str[7] + str[8] + str[9];
pending…
Concat Group
res = str0.concat(str1, str2, str3, str4, str5, str6, str7, str8, str9);
pending…
Concat Seperate
res = str0.concat(str1).concat(str2).concat(str3).concat(str4).concat(str5).concat(str6).concat(str7).concat(str8).concat(str9);
pending…
For Loop
res = "";
for (var i = 0; i < 10; i++) {
  res += str[i];
}
pending…
Array Join
res = str.join();
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