trunc vs round vs floor vs parseFloat to intFastest: round (3.0x faster)
8,253,639 ops/sec
8,166,661 ops/sec
8,155,592 ops/sec
2,769,483 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| trunc | |
| round | |
| floor | |
| parseFloat to int |
| Test name | Executions per second |
|---|---|
| ✓ round | 181,226,768 Ops/sec |
| floor | 179,902,656 Ops/sec |
| trunc | 165,500,736 Ops/sec |
| parseFloat to int | 6,831,086 Ops/sec |