Math.min vs if vs ternaryFastest: if (2.3x faster)
35,192,912 ops/sec
34,885,328 ops/sec
15,531,130 ops/sec
Fastest: ternary (14.8x faster)
607,271,296 ops/sec
534,361,760 ops/sec
40,991,072 ops/sec
Fastest: if (26.4x faster)
311,096,032 ops/sec
301,649,440 ops/sec
11,783,476 ops/sec
Fastest: ternary (1.7x faster)
16,257,832 ops/sec
15,901,036 ops/sec
9,300,313 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Math.min | |
| if | |
| ternary |
| Test name | Executions per second |
|---|---|
| ✓ ternary | 741,108,416 Ops/sec |
| if | 270,818,560 Ops/sec |
| Math.min | 62,191,564 Ops/sec |