The most famous quote from Knuth’s paper “Structured Programming with go to Statements” is this: There is no doubt that the grail of efficiency leads to abuse. Programmers waste e…
Exactly. A 10% decrease in run time for a method is a small optimization most of the time, but whether or not it’s premature depends on whether the optimization has other consequences. Maybe you lose functionality in some edge cases, or maybe it’s actually 10x slower in some edge case. Maybe what you thought was a bit faster, is actually slower in most cases. That’s why you measure when you’re optimizing.
Maybe you took 3 hours of profiling and made a loop 10% faster but you could have trivially rewritten it to run log n times instead of n times…
Exactly. A 10% decrease in run time for a method is a small optimization most of the time, but whether or not it’s premature depends on whether the optimization has other consequences. Maybe you lose functionality in some edge cases, or maybe it’s actually 10x slower in some edge case. Maybe what you thought was a bit faster, is actually slower in most cases. That’s why you measure when you’re optimizing.
Maybe you took 3 hours of profiling and made a loop 10% faster but you could have trivially rewritten it to run log n times instead of n times…