Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Windows
Desktop
2 years ago
Benchmark.js
Math.floor fast
11.6M/s
toPrecision(4).toString()
5.4M/s
(Math.round(*10000)/10000).toString()
5.0M/s
toFixed(4)
4.6M/s
View exact numbers
Test name Executions per second
Math.floor fast 11,578,240 Ops/sec
toPrecision(4).toString() 5,356,138 Ops/sec
(Math.round(*10000)/10000).toString() 5,045,189 Ops/sec
toFixed(4) 4,595,470 Ops/sec
Script Preparation code:
Tests: