Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
Math.floor fast
38.7M/s
(Math.round(*10000)/10000).toString()
14.5M/s
toFixed(4)
13.4M/s
toPrecision(4).toString()
13.2M/s
View exact numbers
Test name Executions per second
Math.floor fast 38,655,864 Ops/sec
(Math.round(*10000)/10000).toString() 14,543,770 Ops/sec
toFixed(4) 13,367,092 Ops/sec
toPrecision(4).toString() 13,180,132 Ops/sec
Script Preparation code:
Tests: