Join vs for

Benchmark created by polkovnikov.ph on


Test runner

Ready to run.

Testing in
TestOps/sec
Join
var a = new Array(100000).join("a") + "bcd";
ready
for
var a = "bcd";
for (var i = 0; i < 100000; ++i) {
    a = "a" + a;
}
ready
for binary
var a = "";
for (var i = 100000, s = "a"; i != 0; i >>= 1) {
    if (i & 1) a += s;
    s += s;
}
ready

Revisions

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

  • Revision 1: published by polkovnikov.ph on
  • Revision 5: published by Khoa Nguyen on