Build String (v2)

Revision 2 of this benchmark created by Sam Foster on


Description

Different string building techniques

Test runner

Ready to run.

Testing in
TestOps/sec
Array join
var str = [],
    html;

for (i = 0; i < 100; i++) {
 str.push('<p>Test</p>');
}

html = str.join('');
ready
String append
var str = '',
    html;

for (i = 0; i < 100; i++) {
 str += '<p>Test</p>';
}

html = str;
ready
String concat
var str = '',
    html;

for (i = 0; i < 100; i++) {
 str = str.concat('<p>Test</p>');
}

html = str;
ready
String append with while
var str = '',
    html, i = 100;

while (i--) {
 str += '<p>Test</p>';
}
html = str;
ready

Revisions

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

  • Revision 1: published by Jenna Smith on
  • Revision 2: published by Sam Foster on