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
28.0M/s
(Math.round(*10000)/10000).toString()
10.8M/s
toPrecision(4).toString()
10.1M/s
toFixed(4)
8.9M/s
View exact numbers
Test name Executions per second
Math.floor fast 27,957,276 Ops/sec
(Math.round(*10000)/10000).toString() 10,818,839 Ops/sec
toPrecision(4).toString() 10,090,059 Ops/sec
toFixed(4) 8,913,889 Ops/sec
Script Preparation code:
Tests: