Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36
Chrome 91
Linux
Desktop
3 years ago
Test name Executions per second
toFixed(2) 6315859.5 Ops/sec
toPrecision(2).toString() 5938405.5 Ops/sec
(Math.round(*100)/100).toString() 5750176.0 Ops/sec
(Math.round(*100) * 0.01).toString() 5968852.5 Ops/sec
customRound(*100) * 0.01.toString() 8328954.5 Ops/sec
Script Preparation code:
Tests:
  • toFixed(2)

  • toPrecision(2).toString()

  • (Math.round(*100)/100).toString()

  • (Math.round(*100) * 0.01).toString()

  • customRound(*100) * 0.01.toString()