3 ms·
Measure first, then optimize. This sounds like good advice, but from experience I've found that optimizing code by adding things like memoization after you've
by onion2k 7y ago
Measure first, then optimize.
This sounds like good advice, but from experience I've found that optimizing code by adding things like memoization after you've discovered it's too slow in the context of an app is a lot harder than than writing something that's efficient to start with, especially if a feature is mature and other parts of the code are resistant to change. There's a balance to strike between spending time writing optimal code and actually shipping, but if there are low-hanging fruit available and you choose not to take advantage of them you'll probably regret it.