3 ms·
Not doing simple mistakes that kill performance for no benefit or choosing option B over A where both take equal effort but B is 20x times more performant shoul
by onion2k 4y ago
Not doing simple mistakes that kill performance for no benefit or choosing option B over A where both take equal effort but B is 20x times more performant should be common sense.
The full quote from Knuth is this;
“The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.”
In your example clearly if there are two approaches and one is 20* faster than the other it's optimization in the right place.
But... it's the "at the wrong times" bit that's actually the most important part. If you have a working solution and you're spending time trying to make it faster without knowing it's too slow then you're trying to optimize at the wrong time. If you know both approaches then it's fine, and good, to pick the faster one. If you don't then you should use the one you know and come back later if you need to.
Most of the time you won't need to.