![](https://csdnimg.cn/release/download_crawler_static/10379667/bg13.jpg)
Xbox is a good example) for several years, and have the time and the need to master
these dark arts. However, the great majority of developers target phones, tablets, or
PCs, which contain an endless variety of microprocessor chips—some of which have
not yet even been designed. Developers of software embedded into products also face
a variety of processors with widely varying architectures. Attempting to learn pro‐
cessor arcana will make most developers crazy and paralyze them with indecision. I
don’t recommend this path. Processor-dependent optimization is simply not fruitful
for most applications, which must by definition run on a variety of processors.
This book is likewise not about learning the fastest operating system–dependent way
to do some operation on Windows, and again on Linux, OS X, and every embedded
operating system. It is about what you can do in C++, including with the C++ stan‐
dard library. Breaking out of C++ to perform an optimization may make it hard for
peers to review or comment on the optimized code. It’s not an action to be taken
lightly.
This book is about learning how to optimize. Any static catalog of techniques or func‐
tions is doomed, as new algorithms are discovered and new language features become
available. Instead, this book provides several running examples of how code may be
improved incrementally, so that the reader becomes familiar with the code tuning
process and develops the mindset that makes optimization fruitful.
This book is about optimizing the coding process as well. Developers mindful of the
runtime cost of their code can write code that is efficient from the start. With prac‐
tice, writing fast code usually takes no longer than writing slow code.
Finally, this book is about performing miracles; about checking in a change and later
hearing a colleague exclaim in surprise, “Wow, what happened? It just started right
up. Who fixed something?” Optimization is something you can also do to your status
as a developer and your personal pride in your craft.
Optimization Is Part of Software Development
Optimization is a coding activity. In traditional software development processes, opti‐
mization takes place after Code Complete, during the integration and testing phase of
a project, when the performance of a whole program can be observed. In an Agile
development process, one or more sprints may be allocated to optimization after a
feature with performance goals is coded, or as needed to meet performance targets.
The goal of optimization is to improve the behavior of a correct program so that it
also meets customer needs for speed, throughput, memory footprint, power con‐
sumption, and so on. Optimization is thus as important to the development process
as coding features is. Unacceptably poor performance is the same kind of problem for
users as bugs and missing features.
2 | Chapter 1: An Overview of Optimization