"It is correct, but is it fast?"
summary
A Ruby state‑machine gem fighting_machine ships a memory leak from a background thread that never stops, prompting adding automated performance assertions using RSpec + spec‑benchmark. Examples show a tiny clamp method moving from ~1.8M to 7.5M iterations/sec after eliminating allocations and using perform_faster and perform_allocations matchers to assert speed and object counts. Scalability tests use exponentially growing inputs against a Merkle tree and BenchmarkTrend to assert linear behavior. Advice: profile to find the hot unit, add performance specs in a separate folder and run them on CI.
AI-written summary · about
chapters (15)
- 0:00Start
- 4:36Perf Testing
- 7:40"Fundamental" change
- 13:00Performance "surprises"
- 16:00"Measuring Empirical Computational Complexity" [2]
- 16:30benchmark-trend
- 17:03Scalability testing algorithm
- 20:12How do we choose the subject of our performance assertion?
- 20:48Unit of work
- 22:18Critical path
- 22:28Intuition is not a reliable indicator for performance improvements!
- 22:40'single' vs "double"
- 23:56Does performance matter?
- 25:20Design vs Optimization
- 26:26Key Takeaways








