Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Chrome 125
Linux
Desktop
2 years ago
Benchmark.js
Math.floor fast
22.8M/s
toPrecision(4).toString()
8.9M/s
(Math.round(*10000)/10000).toString()
8.7M/s
toFixed(4)
7.4M/s
View exact numbers
Test name Executions per second
Math.floor fast 22,838,448 Ops/sec
toPrecision(4).toString() 8,912,708 Ops/sec
(Math.round(*10000)/10000).toString() 8,673,599 Ops/sec
toFixed(4) 7,445,998 Ops/sec
Script Preparation code:
Tests: