const vs join

JavaScript performance comparison

Revision 3 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var hashStore = '########################################';
  var Fiveup ;
  var Tenup ;

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
const
Fiveup = hashStore.substring(0, 5);
Tenup = hashStore.substring(0, 10);
pending…
split
Fiveup = new Array(6).join('#');
Tenup = new Array(11).join('#');
pending…
loop
Fiveup = '';
for (var i = 0; i < 6; i++) {
  Fiveup += '#';
}

Tenup = '';
for (var j = 0; j < 11; j++) {
  Tenup += '#';
}
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.

0 Comments