Hacker News new | ask | show | jobs
by aappleby 103 days ago
This is... not an example of good optimization.

Focusing on micro-"optimizations" like this one do absolutely nothing for performance (how many times are you actually calling Instance() per frame?) and skips over the absolutely-mandatory PROFILE BEFORE YOU OPTIMIZE rule.

If a coworker asked me to review this CL, my comment would be "Why are you wasting both my time and yours?"

3 comments

Optimizing requires a (performane) problem, and often needs a benchmark.

In my view, the article is not about optimizing, but about understanding how things work under the hood. Which is interesting for some.

> If a coworker asked me to review this CL, my comment would be "Why are you wasting both my time and yours?"

If a coworker submitted a patch to existing code, I'd be right there with you. If they submitted new code, and it just so happened to be using this more optimal strategy, I wouldn't blink twice before accepting it.

Among C++ programmers "Best performance" isn't about actual optimization it's a brag with about the same semantic value as for Broadway and so it's not measurable. The woman who wins a Tony for "Best performance in a musical" isn't measurably faster, or smaller, she's just "best" according to some panel. Did audiences like it? Did the musical make money? Doesn't matter, she won a "Best performance" Tony.
Only those that have C++ tatoos and their whole career bound to mastering a single language, selling that knowledge.

Other of us, use it as tool required to integrate with existing products, language runtimes, and SDKs written in C++, which most likely won't get replaced anytime soon.

How is performance not measurable?

Getting into the weeds of what a compiler does with your code is fun.

People have been doing micro optimisations since computers became a thing, you benefit from them every day without realising - and seemingly not appreciating - it.