3 ms·
These sorts of exercises help with performance tuning in the small. One thing you should learn, and many don't, about perf analysis is that you start getting s
by hinkley 3y ago
These sorts of exercises help with performance tuning in the small.
One thing you should learn, and many don't, about perf analysis is that you start getting serious artifacting in the data for tiny functions that get called an awful lot. I've found a lot of tangible improvements from removing 50% of the calls to a function that the profiler claims takes barely any time. Profilers lie. You have to know what they lie about.
When I'm trying to optimize leaf- or near-leaf-node functions I've been known to wrap the call with a for loop that runs the same operation 10, 100, 1000 times in a row, just so I can see if some change has a barely-double-digit effect on performance. These predictions usually hold up in production.
Just be very, very sure not to commit that for loop.
Or use representative data that is ridiculously large compared to the average case.