Script Preparation code:
Tests:

Historical Performance Data aggregated from 18 community runs

Desktop Results:
Chrome 18 runs
Math.floor fast
20.1M/s
(Math.round(*10000)/10000).toString()
7.6M/s
toPrecision(4).toString()
7.1M/s
toFixed(4)
5.2M/s

Fastest: Math.floor fast (3.8x faster)

View exact numbers
  • Math.floor fast: 20,055,864 ops/sec
  • (Math.round(*10000)/10000).toString(): 7,626,493 ops/sec
  • toPrecision(4).toString(): 7,088,945 ops/sec
  • toFixed(4): 5,237,924 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    toFixed(4)
    toPrecision(4).toString()
    (Math.round(*10000)/10000).toString()
    Math.floor fast

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Chrome 139 on Windows
View result in a separate tab
Math.floor fast
68.7M/s
(Math.round(*10000)/10000).toString()
67.5M/s
toPrecision(4).toString()
8.1M/s
toFixed(4)
4.4M/s
View exact numbers
Test name Executions per second
Math.floor fast 68,666,472 Ops/sec
(Math.round(*10000)/10000).toString() 67,501,424 Ops/sec
toPrecision(4).toString() 8,061,111 Ops/sec
toFixed(4) 4,404,910 Ops/sec