JSON vs Regex vs String search vs indexOfFastest: Regex (3.9x faster)
566,395 ops/sec
433,613 ops/sec
430,246 ops/sec
143,887 ops/sec
Fastest: indexOf (9.0x faster)
1,284,454 ops/sec
1,205,031 ops/sec
721,836 ops/sec
141,956 ops/sec
Fastest: Regex (3.6x faster)
294,143 ops/sec
225,103 ops/sec
218,717 ops/sec
82,176 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| JSON | |
| Regex | |
| String search | |
| indexOf |
| Test name | Executions per second |
|---|---|
| ✓ Regex | 298,802 Ops/sec |
| indexOf | 230,594 Ops/sec |
| String search | 228,834 Ops/sec |
| JSON | 111,144 Ops/sec |