Andrei Alexandrescu gave this talk on optimization tips for C++. He claims you should aim to:
- Measure performance against a baseline
- Choose algorithms that use the least heavyweight operations
- Reduce array writes
The slides are also available.
Measuring gives you a leg up on experts who don’t need to measure
He also presents a handy ordering of different integral/floating point operations in terms of cost. The techniques (which he has internalised to give a gut feel of whether some improvement will produce a speed-up) are illustrated with a classic interview question (convert an integer to ascii) that is heavily used at Facebook.
The underlying message of this presentation is that the cost of one engineer spending time producing some pretty esoteric code with massive performance benefits is more than outweighed by the savings in terms of data centre costs (due to improved speed, you can scale back spend on servers).