8. Need for Speed – Performance and Optimization
Learning Objectives
By the end of this chapter, you will be able to:
- Time your code performance manually
- Use source code instrumentation to measure code execution time
- Use the perf tool to analyze program performance
- Use the godbolt compiler explorer tool to analyze machine code generated by a compiler
- Use compiler flags to generate better code
- Apply code idioms that result in performance
- Write cache-friendly code
- Apply algorithm-level optimizations to real-world problems
In this chapter, we will explore concepts that will allow us to write fast code in general and several practical techniques that apply to C++ in particular.