Scott Meyers Training Courses
High-Performance C++ Programming
Rare is the C++ application where high performance is not a criterion for success. This seminar, based on Scott's famous books (Effective C++, More Effective C++, and Effective STL), focuses on how to best use the language and standard template library (STL) to create small, fast code.
Course Highlights
Participants will gain:
- An understanding of when and why compilers create temporary objects and how to prevent them from doing it.
- Insights into the role of inlining in improving -- or decreasing -- performance.
- An assortment of techniques for using the STL most efficiently.
- An understanding of the pros and cons of reference counting.
Who Should Attend
Systems designers, programmers, and technical managers involved in the design, implementation, and maintenance of production libraries and applications using C++. Participants should already know the basic features of C++ (e.g., classes, inheritance, virtual functions, templates), but expertise is not required. People who have learned C++ recently, as well as people who have been programming in C++ for many years, will come away from this seminar with useful, practical, proven information.
Format
Lecture and question/answer. There are no hands-on exercises, but participants are welcome to use their computers to experiment with the course material as it is presented.
Length
One full day (six to seven lecture hours).
Detailed Topic Outline
- The 80-20 rule and program profiling.
- Language issues:
- Eliminating unnecessary temporary objects:
- Pass by reference-to-const instead of by value.
- Defer object definitions as long as possible.
- Prefer initialization to assignment in constructors.
- Consider overloading to avoid implicit type conversions.
- Consider using op= instead of op.
- Facilitate the return value optimization.
- Consider a more C-like design.
- Don't try to return a reference when you must return an object:
- Returning a reference to a local object.
- Returning a reference to a heap-allocated object.
- Returning a reference to a local static object.
- The pros and cons of inlining:
- Inlining and compiler optimization.
- Automatic inlining.
- Linktime inlining.
- When custom memory managers make sense.
- Eliminating unnecessary temporary objects:
- Library issues:
- Use reserve to minimize memory reallocations in
vector and string.
- Using "the swap trick" to perform "shrink to fit."
- Prefer range member functions to single-element versions for sequence containers.
- Prefer function objects to functions.
- Why sort is typically faster than qsort.
- Why sorted vectors can be superior to
sets and maps for lookup-intensive applications.
- std::binary_search vs. std::lower_bound vs. std::equal_range
- STL containers based on hash tables.
- Use reserve to minimize memory reallocations in
vector and string.
- Reference Counting:
- A reference-counted string implementation.
- How changing the implementation changed the interface.
- How threading issues can turn an optimization into a pessimization.
- Further Reading
- Additional Efficiency Topics
For more information on this course, contact Scott directly.
