-
Book Overview & Buying
-
Table Of Contents
Polished Ruby Programming - Second Edition
By :
Sometimes you have a ball of mud, where everything is slow and you cannot figure out why. This is an unfortunate situation to be in. Unfortunately, there is no general advice that will work in all cases. However, there are a few approaches that you can try.
The best place to look first is code that allocates a lot of objects. Allocating too many objects is probably the most common reason that Ruby code is slow. If you can figure out a way to allocate fewer objects, that can improve performance. This is especially true if you can remove allocations of complex objects that themselves allocate a lot of objects. One library that can help you figure out which places to start reducing object allocations is called memory_profiler, which can show how much memory and how many objects are allocated and retained by gem, by file, and by line.
Next, see whether there is a way to rearrange the logic so that code that is currently executed in the most common code...
Change the font size
Change margin width
Change background colour