Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Windows
Desktop
one year ago
Benchmark.js
Math.floor fast
11.5M/s
toPrecision(4).toString()
4.4M/s
(Math.round(*10000)/10000).toString()
3.9M/s
toFixed(4)
3.8M/s
View exact numbers
Test name Executions per second
Math.floor fast 11,502,892 Ops/sec
toPrecision(4).toString() 4,385,502 Ops/sec
(Math.round(*10000)/10000).toString() 3,928,262 Ops/sec
toFixed(4) 3,802,334 Ops/sec
Script Preparation code:
Tests: