YA String Concat (v8)

Revision 8 of this benchmark created by Esailija on


Description

Benchmarking string methods given in airbnb's style guide

//Show that results are equal when JITd

Preparation HTML

<script>
function a() {
    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.';

}

function b() {
    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.';

}

function c() {
    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.';
}

function d() {
    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.';
}

var l = 10000;

while (l--) {
    a()
    b()
    c()
    d()
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Long string without breaks
a()
ready
Long string with breaks
b()
ready
Long string with concats
c()
ready
Long string with concats on one line
d()
ready

Revisions

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