Script Preparation code:
x
 
const length = 9999;
var input = "";
for (let i = 0; i <= length; i +=1) {
    input += Math.floor(Math.random()*10);
}
Tests:
  • Math.max

     
    (n => Math.max(...n))(input)
  • For...of

     
    (function(n) {
        let min = 1;
        for (digit of n.split('')) {
            if (digit === 9) {
                return 9;
            }
            if (digit > min) {
                min = digit;
            }
        }
        return min;
    })(input)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Math.max
    For...of

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Chrome 116 on Windows
View result in a separate tab
Test name Executions per second
Math.max 4532.5 Ops/sec
For...of 405.5 Ops/sec