string concat vs array join vs concat method (v37)

Revision 37 of this benchmark created on


Setup

var words = ['this', 'is', 'a', 'test'];
  
  var text = words[0];
  
  var a = [words[0]];
  
  var i;
  
  var text2, text3 = [];

Test runner

Ready to run.

Testing in
TestOps/sec
Concat
for(i = 1; i < 10000; ++i)
{
    text += ' ' + words[i & 3];
}

text2 = text;
ready
Join
for(i = 1; i < 10000; ++i)
{
    a.push(words[i & 3]);
}

text2 = a.join(' ');
ready
Concat method
for(i = 1; i < 10000; ++i)
{
    text3.concat(words[i & 3]);
}

text2 = text3;
ready

Revisions

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