Concat vs Join (v5)

Revision 5 of this benchmark created by Benjamin Eidelman on


Setup

count = 1000;

Test runner

Ready to run.

Testing in
TestOps/sec
+=
var str = "";
for (var i = 0; i < count; i++)
str += "Test String";
ready
Join
var str = new Array();
for (var i = 0; i < count; i++)
str[i] = "Test String";

str.join("");
ready
Concat
var str = "";
for (var i = 0; i < count; i++)
str.concat("Test String");
ready
Concat via Apply
var str = "";
for (var i = 0; i < count; i++)
String.prototype.concat.apply(str, ["Test String"]);
ready
Push+Join
var str = [];
for (var i = 0; i < count; i++)
str.push("Test String");
str.join("");
ready

Revisions

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

  • Revision 5: published by Benjamin Eidelman on