Concatenation vs Array Join (v19)

Revision 19 of this benchmark created by Qantas94Heavy on


Setup

var i,
          str,
          tmp = [],
          cnt = 10000;

Test runner

Ready to run.

Testing in
TestOps/sec
Concatenation 1
for (i = 0, str = ''; i < cnt; ++i) {
  str += 'a';
}
ready
Array.prototype.join 1
for (i = 0, tmp.length = 0; i < cnt; ++i) {
    tmp.push('a');
}
str = tmp.join('');
ready
Array.prototype.join 2
for (i = 0, tmp.length = 0; i < cnt; i++) {
 tmp[i] = 'a';
}

str = tmp.join('');
ready

Revisions

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