YA String Concat

JavaScript performance comparison

Revision 3 of this test case created

Info

Benchmarking string methods given in airbnb's style guide

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/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.';
 
pending…
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.'
;
 
pending…
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.';
pending…
define empty String and put the contnent line by line.
var errorMessage = '';

errorMessage += 'This is a super long error that ';
errorMessage += 'was thrown because of Batman.';
errorMessage += 'When you stop to think about ';
errorMessage += 'how Batman had anything to do ';
errorMessage += 'with this, you would get nowhere ';
errorMessage += 'fast.';
pending…
Use an array
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();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment