Script Preparation code:
AخA
 
  var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  
  function sum_recurse(arr, i=0, acc=0) {
   if (i > arr.length)
     return acc;
  acc += i[i];  
  return sum_recurse(arr, i + 1, acc);
  }
  
  function sum_while(arr) {
   var total = 0,
       i = 0,
       len = arr.length;
  
   while (i < len) {
    total += arr[i++];
   }
  
   return total;
  }
  
  function sum_for(arr) {
   var total = 0,
       len = arr.length;
  
   for (var i = 0; i < len; i++) {
    total += arr[i];
   }
  
   return total;
  }
Tests:
  • recursion

     
    sum_recurse(nums)
  • while loop

     
    sum_while(nums)
  • for loop

     
    sum_for(nums)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    recursion
    while loop
    for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Chrome 112 on Windows
View result in a separate tab
Test name Executions per second
recursion 770381.5 Ops/sec
while loop 8892113.0 Ops/sec
for loop 8894490.0 Ops/sec