this post was submitted on 22 Jun 2025
52 points (94.8% liked)
Programming
21072 readers
345 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
No, that’s not what people mean. They mean measure first, then optimize. Small optimizations may or may not be worth it. You don’t know until you measure using real data.
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...