4 ms·
This is an interesting observation, and confirms the way I optimise code: 1) Create a benchmark (some code that performs the task that I want to optimise), and
by jakobegger 11y ago
This is an interesting observation, and confirms the way I optimise code:
1) Create a benchmark (some code that performs the task that I want to optimise), and measure the absolute time it needs.
2) Use a profiler to see where most of the time is spent. Optimise that code.
3) Run benchmark to see if your optimisation are effective.
Or, in other words: the percentage tells you where to focus your effort. The absolute time tells you how successful your optimisation is.
- ot 11y agoThis is the obvious strategy, but it's not always applicable. For example when profiling a long-running service, or a kernel, there's no "absolute time it needs", you need other proxies of running time such as the CPU usage percentage, but even that is not noise-free. So if you just run "perf" on it, you need to be aware of this fallacy.
- blueblob 11y agoI am pretty much a novice in program optimization, but doesn't `perf` sample clock cycles? So in effect CPU usage percentage doesn't matter as much since it's not using wall clock time?