HTML Preparation code:
AخA
 
1
var array = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 10000))
Script Preparation code:
 
var array = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 10000))
Tests:
  • reverse

    x
     
    array.forEach(n => {
      const repeat = Math.sqrt(n);
      const result = [[], []];
      for (let i = 1; i <= repeat; i++) { 
              if(n % i === 0) {
                  result.push(i);
                  if (i !== repeat) result.push(n / i);
              }
      }
      result.sort().reverse()[0];
      }
    )
  • sort

     
    array.forEach(n => {
      const repeat = Math.sqrt(n);
      const result = [[], []];
      for (let i = 1; i <= repeat; i++) { 
              if(n % i === 0) {
                  result.push(i);
                  if (i !== repeat) result.push(n / i);
              }
      }
      result.sort()[result.length-1];
      }
    )
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    reverse
    sort

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Chrome 130 on Windows
View result in a separate tab
Test name Executions per second
reverse 30.1 Ops/sec
sort 30.3 Ops/sec