Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
Math.floor fast
163.9M/s
(Math.round(*10000)/10000).toString()
138.2M/s
toPrecision(4).toString()
13.4M/s
toFixed(4)
8.9M/s
View exact numbers
Test name Executions per second
Math.floor fast 163,922,912 Ops/sec
(Math.round(*10000)/10000).toString() 138,189,568 Ops/sec
toPrecision(4).toString() 13,439,743 Ops/sec
toFixed(4) 8,926,744 Ops/sec
Script Preparation code:
Tests: