YA String Concat (v14)

Revision 14 of this benchmark created by Gaby on


Description

Benchmarking string methods given in airbnb's style guide

Setup

var items = ['This is a super long error that ',
      'was thrown because of Batman.',
      'When you stop to think about ',
      'how Batman had anything to do ',
      'with this, you would get nowhere ',
      'fast.'];

Test runner

Ready to run.

Testing in
TestOps/sec
Long string without breaks
var errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
 
ready
Long string with breaks
var errorMessage = 'This is a super long error that \
was thrown because of Batman. \
When you stop to think about \
how Batman had anything to do \
with this, you would get nowhere \
fast.';
 
ready
Long string with concats
var errorMessage = 'This is a super long error that ' +
  'was thrown because of Batman.' +
  'When you stop to think about ' +
  'how Batman had anything to do ' +
  'with this, you would get nowhere ' +
  'fast.';
ready
Long string with join()
var errorMessage = ['This is a super long error that ',
  'was thrown because of Batman. ',
  'When you stop to think about ',
  'how Batman had anything to do ',
  'with this, you would get nowhere ',
  'fast.'].join('');
ready
Long string with join() on existing table (to remove the array creation from the benchmark)
var errorMessage = items.join('');
ready

Revisions

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