String concat vs. Array .join() (v3)

Revision 3 of this benchmark created by DTrejo on


Description

This testcase compares performance of string concatenation (+) versus the native Array.prototype.join() method.

Test runner

Ready to run.

Testing in
TestOps/sec
String concat
var result = "This" + " is" + " a" + " very" + " long" + " string." + " Well," + " not" + " that" + " long" + " I" + " guess.";
ready
Array.join
var result = ["This", " is", " a", " very", " long", " string.", " Well,", " not", " that", " long", " I", " guess."].join('');
ready
individual concat
var result = '';
result += "This";
result += " is";
result += " a";
result += " very";
result += " long";
result += " string.";
result += " Well,";
result += " not";
result += " that";
result += " long";
result += " I";
result += " guess.";
ready
individual push
var result = [];
result.push("This");
result.push(" is");
result.push(" a");
result.push(" very");
result.push(" long");
result.push(" string.");
result.push(" Well,");
result.push(" not");
result.push(" that");
result.push(" long");
result.push(" I");
result.push(" guess.");
result = result.join('');
ready

Revisions

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