concat/join-with-push/join-without-push (v158)

Revision 158 of this benchmark created on


Setup

function makeid() {
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  
    for (var i = 0; i < 5; i++)
      text += possible.charAt(Math.floor(Math.random() * possible.length));
  
    return text;
  }
  
  
  var data = [];
  
  for (var i = 0; i < 10000; i++) {
    data.push(makeid());
  }

Test runner

Ready to run.

Testing in
TestOps/sec
string-templates
for (var res = '', i = 0; i < data.length; i++) {
  res = `${res}${data[i]}`;
}
ready
join-with-push
for (var res = [], i = 0; i < data.length; i++) {
  res.push(data[i]);
}
res = res.join('');
ready
concat
for (var res = '', i = 0; i < data.length; i++) {
  res += data[i];
}
ready
join-without-push
var res = [];
res.length = data.length;
for (i = 0; i < data.length; i++) {
  res[i] = data[i];
}
res = res.join('');
ready

Revisions

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