Back

Ever stared at a 50k row export and thought "are my enums slowing this down?"

I did. So I rewrote the whole thing to use pre-cached arrays instead of tryFrom() on every row, moved JSON decoding to raw SQL, and benchmarked both versions carefully.
Result? 16ms difference. Literally noise.

Turns out PHP 8.1 enums are singletons - same instance every time, no allocations, no GC pressure. Your real bottleneck is I/O and formatting, not enums.
Use tryFrom(), this is fine.
dev.to/tegos/php-enums-are-not-your-bottleneck-heres-proof-1887

12

  • No matching results...
  • Searching...

/ 1000

Poll Options