Minimize External Factors

It’s obvious that before measuring performance you need to free up memory, ensure that nothing else runs in parallel, and that no disk I/O happens. But there are a few things you might want to do beyond that.

Disable Dynamic CPU Frequency Scaling

The first thing to consider is disabling dynamic CPU frequency scaling, not because scaling makes your program run slower, but because two separate program runs may be incomparable because they’re executed with the CPU capped at different frequencies. That’s why it’s a good idea to disable CPU frequency scaling if you can.

On Linux, the governor defines the current CPU frequency. By default the ondemand governor is used, meaning that CPU speed will change dynamically depending ...

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.