join/concat (v44)

Revision 44 of this benchmark created on


Description

A simpler check for testing for concat vs join outside of a loop (not building a string in a loop, typical use case would be to use a var in the string).

Preparation HTML

<script>
  var str = 'string';
  var barr = ['this', str, ' is', str, ' a', str, ' to', str, ' test', str, ' if', str, ' there', str, ' is', str, ' any', str, ' difference', str, ' between', str, ' concat', str, ' and', str, ' join'];
  var sarr = ['this', ' is', ' a', str];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
concat
var a = 'this' + str + ' is' + str + ' a' + str + ' to' + str + ' test' + str + ' if' + str + ' there' + str + ' is' + str + ' any' + str + ' difference' + str + ' between' + str + ' concat' + str + ' and' + str + ' join';
ready
join
var a = barr.join('');
ready
concat shorter
var a = 'this' + ' is' + ' a' + str;
ready
join shorter
var a = sarr.join('');
ready
concat in a loop
var str = '';
for (var i = 0; i < barr.length; i++) {
  str += barr[i];
}
ready

Revisions

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