const v var (thru recursion)

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const cr = function(x) { if (x !==0) cr(x-1); }
  
  var vr = function(x)   { if (x !==0) vr(x-1); }
  
  const carray = [0];
  var   varray = [0];
  
  const cr2 = function(x,_carray) { 
     const carray = _carray;
      carray[0]++;
      if (x !==0) cr2(x-1,carray)
  }
  
  const vr2 = function(x,varray) {
      varray[0]++; 
      if (x !==0) vr2(x-1,varray) 
  }

};
</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
constant recursion
cr(2000);
pending…
var recursion
vr(2000);
pending…
constant recusion with param
cr2(1000,carray)
pending…
var recursion with param
vr2(1000,varray)
pending…

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

0 Comments