tail-vs-no-tail-1 (v4)

Revision 4 of this benchmark created by Amjad Masad on


Preparation HTML

<script>
  (function() {
   var stackSize = 0;
  
   tail = function(fn, args) {
    ++stackSize > 50 ? (stackSize = 0, setTimeout("fn.apply(null, args)", 0)) : fn.apply(null, args);
  
   };
  })();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
without-tail
function test(n) {
 if (++n >= 10000) {
  return;
 } else {
  test(n);
 }
}

test(0);
ready
with-tail
function test(n) {
 if (++n >= 10000) {
  return;
 } else {
  tail(test, [n]);
 }
}

test(0);
ready

Revisions

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

  • Revision 4: published by Amjad Masad on