regex vs Slice vs Prealloc slice vs Substr vs LoopFastest: regex (1.2x faster)
8,431 ops/sec
7,370 ops/sec
7,055 ops/sec
7,006 ops/sec
6,795 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| regex | |
| Slice | |
| Prealloc slice | |
| Substr | |
| Loop |
| Test name | Executions per second |
|---|---|
| ✓ regex | 8,664 Ops/sec |
| Prealloc slice | 7,148 Ops/sec |
| Substr | 6,983 Ops/sec |
| Slice | 6,781 Ops/sec |
| Loop | 6,501 Ops/sec |