Chapter 14: Optimizing Your Library
Optimization is often not needed in Ruby, but when it is needed, it should be approached in a principled manner, lest you waste time optimizing the wrong code. Nobody likes slow code, but there is a reason that premature optimization is considered the root of all evil.
In this chapter, you'll learn the importance of profiling in order to decide what to optimize, how the best optimization is deleting code or delaying the execution of code, and what to do when it looks like all parts of your application are slow.
We will cover the following topics in this chapter:
- Understanding that you probably don't need to optimize code
- Profiling first, optimizing second
- Understanding that no code is faster than no code
- Handling code where everything is slow
By the end of this chapter, you'll have a better understanding of when and how to optimize your application.