concat vs + vs join (v48)

Revision 48 of this benchmark created on


Description

How to concat strings faster.

Setup

var i = Math.floor(Math.random() * 10);
    
    var a = '' + i++;
    var b = '' + i++;
    var c = '' + i++;
    var d = '' + i;

Test runner

Ready to run.

Testing in
TestOps/sec
concat
a.concat(', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d, ', ', b, ', ', c, ', ', d);
ready
+
a + ', ' + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d + b + ', ' + c + ', ' + d;
ready
join
[a, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d, b, c, d].join(', ');
ready

Revisions

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