3 ms·
A popular school of thought says to not worry about such things until you run into a performance issue and through profiling you find a bottleneck to optimize.
by adrusi 11y ago
A popular school of thought says to not worry about such things until you run into a performance issue and through profiling you find a bottleneck to optimize.
Database requests, and really any IO, is never appropriate to use like this, I'm refering to stuff like itoa.
When you follow this principle, you end up with software that is exactly as performant as it needs to be (or whatever arbitrary standards were set).
I started following HN when I was a novice programmer, so I do appreciate seeing content appropriate for beginners.
- Cthulhu_ 11y agoYeah, I'd like to be in the 'not worry about such things' school of thought; personally I don't like the re-calling of methods all the time, because it doesn't look elegant, but in terms of performance it shouldn't matter - I'd like to think the compiler can do some optimizations there. Of course, the compiler may not realize or want to assume the result of the methods are the same for every loop. But still, it should be possible for it to infer that, and optimize this developer oversight.
- JoeAltmaier 11y agoFor instance if Itoa were a const method (is that a Go thing?) the compiler can make the optimization automatically.
- deleted 11y ago[deleted]
- tetha 11y agoIn my book, some people are taking the quote "Premature optimization is bad" too far. To me, there is a difference between optimization of some kind, and not writing dumb code. After some experience, bulk loading data in a batch job, avoiding high complexities if you can, trusting your frameworks is not part of smart optimizations - that's just writing proper code. Optimization in todays world starts when you're looking at reducing communication volume, lock contention, utilizing your persistence better, replacing locks with atomic operations, ... Those things shouldn't be done on a whim without measurements, because they will make code a lot harder for non-obvious reasons.
- agumonkey 11y agoPython is a fun vessel for that kind of things, it's sensitive to function lookups, when profiling you really see the timings drop with local rebinding.