Takeaways

We saw in this chapter that there are only three things that you need to consider to make your Ruby code faster:

  • Optimize memory by avoiding extra allocations and memory leaks.

  • Write faster iterators that take both less time and memory.

  • And finally, write less Ruby code by letting specialized tools do their job.

The beauty of these techniques is that you can apply them to any Ruby program to make it up to ten times faster. But the majority of the Ruby developers are writing Rails applications, so it’s now time to dive deeper and apply our optimization techniques to Ruby on Rails.

Get Ruby Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.