Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 OPR/97.0.0.0
Opera 97
Windows
Desktop
2 years ago
Test name Executions per second
trunc 4661967.0 Ops/sec
round 4663839.0 Ops/sec
floor 4659950.5 Ops/sec
parseFloat to int 1755145.4 Ops/sec
Tests:
  • trunc

    AخA
     
    Math.trunc(13.37)
    Math.trunc(13.67)
  • round

     
    Math.round(13.37)
    Math.round(13.67)
  • floor

     
    Math.floor(13.37)
    Math.floor(13.67)
  • parseFloat to int

     
    parseFloat(12.17.toFixed())
    parseFloat(12.97.toFixed())