Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Windows
Desktop
2 years ago
Benchmark.js
Math.floor fast
31.0M/s
toPrecision(4).toString()
11.6M/s
(Math.round(*10000)/10000).toString()
11.5M/s
toFixed(4)
10.5M/s
View exact numbers
Test name Executions per second
Math.floor fast 31,028,348 Ops/sec
toPrecision(4).toString() 11,579,126 Ops/sec
(Math.round(*10000)/10000).toString() 11,532,146 Ops/sec
toFixed(4) 10,464,598 Ops/sec
Script Preparation code:
Tests: