Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Chrome 129
Windows
Desktop
one year ago
Benchmark.js
Math.floor fast
15.8M/s
(Math.round(*10000)/10000).toString()
6.0M/s
toPrecision(4).toString()
5.4M/s
toFixed(4)
4.6M/s
View exact numbers
Test name Executions per second
Math.floor fast 15,767,684 Ops/sec
(Math.round(*10000)/10000).toString() 5,979,311 Ops/sec
toPrecision(4).toString() 5,435,240 Ops/sec
toFixed(4) 4,565,192 Ops/sec
Script Preparation code:
Tests: