What Makes Ruby Code Slow
To learn what makes Ruby code fast, we must understand what makes Ruby code slow.
If you’ve done any performance optimization in the past, you probably think you know what makes code slow. You may think that even if you haven’t done performance optimization. Let me see if I can guess what you think.
Your first guess is algorithmic complexity of the code: extra nested loops, computations, that sort of stuff. And what would you do to fix the algorithmic complexity? Well, you would profile the code, locate the slow section, identify the reason for the slowness, and rewrite the code to avoid the bottleneck. Rinse and repeat until fast.
Sounds like a good plan, right? However, it doesn’t always work for Ruby code. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access