When it comes to writing high-performance code, I’ve received a lot of advice over the years, and have heard a lot of qualified people express a lot

Programming Performance Myths vs. Realities

submited by
Style Pass
2024-11-12 08:30:05

When it comes to writing high-performance code, I’ve received a lot of advice over the years, and have heard a lot of qualified people express a lot of very strong opinions about what makes a computer program run fast or slow. Coming in as a young programmer, it can be difficult to decide which advice and opinions to follow, so I’ve typically tried to implement different ways of writing my code, and then measure which way(s) perform the best.

I wanted to share some of the most commonly repeated performance tips that I’ve received over the years, and discuss which ones have held up under rigorous testing and which have not. Calling these myths vs. realities might be a little bit extreme (if a claim is true 90% of the time, is the 10% when it’s wrong enough to justify calling it a myth?), but hopefully the reader can look past the slight hyperbole.

This is a claim that I’ve heard most often from modern C++ developers, particularly those who tend to prefer a more object-oriented programming approach. The idea is that the overhead of a virtual function call is small enough that the programmer does not need to worry about it.

Leave a Comment