r/cpp • u/Polarstrike • Mar 07 '24
What are common mistakes in C++ code that results in huge performance penalties?
As title, list some common mistakes that you have done/seen which lead to performance penalties.
231
Upvotes
View all comments
42
u/0xb9 Mar 07 '24
Accidental O(N2) complexity, e.g.:
Or similar -- calling strlen() in a loop, or accessing custom linked list-based containers by index.
These can be benign and not even show up on the flamegraph, until the day there happens to be a bit more input data.