4 ms·
Basically it can be summed up to "don't optimize until you've identified the critical paths"
by anaphor 7y ago
Basically it can be summed up to "don't optimize until you've identified the critical paths"
- defined 7y agoThat’s oversimplifying it. Knuth was writing about micro-optimizations, like writing a section of code in assembly language to shave off some milliseconds from a critical section of code. What many people today mean by optimization is a far cry from that. Here’s a real-life example. Some code was super-slow and nobody could figure out why. It took only a minute to see the code was passing a string (in C++) by value, causing unnecessary copy construction and destruction (in a tight loop, to boot). Writing that code by passing a const reference in the first place is Good Coding 101, but many people might consider that “premature optimization”.