3 ms·
Premature optimization is time spent not optimizing things that actually matter. In my own circles, it's the accusation legitimately levied against the clowns
by MaulingMonkey 5y ago
Premature optimization is time spent not optimizing things that actually matter.
In my own circles, it's the accusation legitimately levied against the clowns who simultaniously write macros instead of functions out of fears that the compiler could theoretically ignore a __forceinline keyword - or if you're lucky, optimizing some microbenchmark while pessimizing overall program performance - and in the next breath writing O(scary) code that'll be invoked with large enough N to demolish any savings from micro-optimizations.
That is, despite optimizing, these are people who, despite an obsession with performance, are still treating the performance of their overall programs as an afterthought. Because they don't actually care about performance as much as they say: they care about showing off and flexing their coding skills by making a mess.
Well, the phrase itself doesn't help guide these people towards real performance engineering, but they're typically stubborn enough to ignore the phrase, and must instead be goaded into using a profiler or generating benchmarks, which can then be picked apart when they optimize away the actual execution of everything at compile time, teaching by way of concrete example at least a little bit about generating better microbenchmarks, which they can use to show off and flex more effectively instead.
- liveoneggs 5y ago> are still treating the performance of their overall programs as an afterthought Because that is harder to test
- bodge5000 5y agoThat doesnt sound like premature optimisation to me. A problem certainly, but premature optimisation should be exactly what it sounds like; optimising something before it needs optimisation. Or perhaps it frequently manifests in that way, but I wouldnt say thats what it is. I know that in my case its much more general, usually because my approach (when Im working on personal projects of course) to optimisation is to change the approach rather than change the code. As you say, overly optimised code is difficult to read and maintain, which in my view is a problem of optimisation itself, so I just try to find compromise and do something thats more efficient. But I'd still call that premature optimisation, because its rarely triggered by a problem.