Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/131.0.6778.73 Mobile/15E148 Safari/604.1
Chrome Mobile iOS 131
iOS 18.1.1
Mobile
4 months ago
Test name Executions per second
trunc 10067463.0 Ops/sec
round 9707678.0 Ops/sec
floor 9218248.0 Ops/sec
parseFloat to int 4260608.5 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())