Ruby Developer's Guide

Chapter 8: Profiling and Performance Tuning

Introduction

Believe it or not, performance should not be the first thing on your mind when designing and writing programs. If you prematurely optimize your programs or designs, they will tend to be more complex and error-prone, harder to understand, and more difficult to maintain. Concentrate first on getting a given program to work and adding in the needed features before shifting your focus to how fast it will execute. Otherwise, you can prematurely alter your program by changing the algorithm, adding code to cache results or using different data structures. Another reason not to start optimizing early is that you simply will not know what parts of your program take the most time. Chances are, you'll have to focus on performance at some point because your program is too slow, but that should come later.

If you discover that the application you've developed is slow, the first thing to ask yourself is: Does it really matter? It does if endless tweaking causes your program to ship too late to be useful or if it does not arrive at all. But often, poor performance is more of a nuisance than a disaster. To settle this, you have to time your program using realistic input data, and you have to keep in mind that next year's computers will be twice as fast. If you put your efforts into performance instead of adding needed features and weeding out bugs, you may end up with a fast but useless program.

When you are...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Industrial Winches
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.