Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Chrome 124
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
Math.floor fast
12.6M/s
toPrecision(4).toString()
4.6M/s
(Math.round(*10000)/10000).toString()
4.5M/s
toFixed(4)
3.6M/s
View exact numbers
Test name Executions per second
Math.floor fast 12,615,887 Ops/sec
toPrecision(4).toString() 4,566,074 Ops/sec
(Math.round(*10000)/10000).toString() 4,475,601 Ops/sec
toFixed(4) 3,569,951 Ops/sec
Script Preparation code:
Tests: