Running Faster, Getting Smaller

Every program can be made to run faster or to use less memory.

Many programmers claim to be able to predict what makes a program fast or slow, big or small. However, experience shows that programmers are not usually good at guessing in advance which parts of their programs will cause performance problems. And often, by trying to optimize a program prematurely, a programmer will not only create a slower, larger program, but will also make it unreadable and unmaintainable.

The best course is to create a well-structured program and then use tests to find what's slow or big. This enables you to focus on the features of C++ while programming and thus build a program that is less likely to need dramatic optimization. ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION 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.