Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
Math.floor fast
36.7M/s
(Math.round(*10000)/10000).toString()
13.7M/s
toPrecision(4).toString()
12.9M/s
toFixed(4)
12.5M/s
View exact numbers
Test name Executions per second
Math.floor fast 36,683,112 Ops/sec
(Math.round(*10000)/10000).toString() 13,676,822 Ops/sec
toPrecision(4).toString() 12,932,183 Ops/sec
toFixed(4) 12,524,611 Ops/sec
Script Preparation code:
Tests: