Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Windows
Desktop
2 years ago
Benchmark.js
Math.floor fast
17.3M/s
(Math.round(*10000)/10000).toString()
6.6M/s
toPrecision(4).toString()
6.1M/s
toFixed(4)
5.3M/s
View exact numbers
Test name Executions per second
Math.floor fast 17,273,280 Ops/sec
(Math.round(*10000)/10000).toString() 6,579,387 Ops/sec
toPrecision(4).toString() 6,116,778 Ops/sec
toFixed(4) 5,310,576 Ops/sec
Script Preparation code:
Tests: