Script Preparation code:
AخA
 
var number = Math.random() * 1000;
Tests:
  • Math.max/min

     
    return Math.max(250, Math.min(750, number));
  • if

     
    if(number < 250) return 250;
    if(number > 750) return 750;
    return number;
  • ternary

     
    return number < 250 ? 250 : (number > 750 ? 750 : number);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Math.max/min
    if
    ternary

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.63
Chrome 104 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Math.max/min 5077461.5 Ops/sec
if 24330970.0 Ops/sec
ternary 24273124.0 Ops/sec