YA String Concat (v28)

Revision 28 of this benchmark created by Philip on


Description

Benchmarking string methods given in airbnb's style guide

Setup

function t(s,d){
     for(var p in d)
       s=s.replace(new RegExp('{'+p+'}','g'), d[p]);
     return s;
    }
    var man = "so";

Test runner

Ready to run.

Testing in
TestOps/sec
Long string without breaks
var errorMessage = 'This' + so + ' 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
TEMPLATE
t("This {man} is a super long error that was thrown because of Batman. When you stop to think about how Batman {who} had anything to do with this, you would get nowhere fast. {yo}", { man: "so", who: "JavaScript", yo: "cool" });
 
ready

Revisions

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