Writing Fast Ruby
summary
Argues that simple source-level changes produce real, measurable wins using Benchmark‑ips on Ruby 2.2. Shows concrete swaps that exceed the 12% target: avoid allocating a Proc and call the block directly (often tens of percent, sometimes several× faster), use in-place/hash mutation instead of repeated merge (2×+), use tr instead of gsub for single-char replacements (≈5×), prefer indexed loops for hot code (up to 80% faster). Presents patched examples and recommends benchmarking your version before changing.
AI-written summary · about
chapters (15)
- 0:00Introduction to optimization
- 3:38Optimization levels in Ruby
- 11:50Benchmarking tools
- 12:57Source code optimization
- 17:12Symbols vs blocks
- 20:09Optimizing map and flat_map
- 23:45Bang methods
- 26:54Hash operations optimization
- 29:26Replace gsub with tr
- 31:55Parallel variable assignment
- 33:03Exceptions and flow control
- 34:54Index loops vs each_with_index
- 37:23Optimization tips
- 40:36Ruby community and future
- 42:26Q&A








