String concatenation: using += vs using array (v5)

Revision 5 of this benchmark created on


Description

Tests the performance difference of using two different ways of concatenating strings. The two TCs produce the same result.

Preparation HTML

<script>
  var length = 1500;
  var html = [];
  var str = "";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
+=
str = "";
while (str.length < length) {
  str += '0';
}
ready
array
str = "";
while (html.length < length) {
  html.unshift('0');
}
str = html.join("");
ready

Revisions

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