There are two different tasks: measuring performance and finding problems.
To measure the time it takes, you must expect variability, because it depends on what else is going on in the machine. This is normal.
To find problems, what you need to know is the percentage of time used by various activities. The percentage does not change too much, as a function of other things, and the exact value of the percentage in any case does not matter much.
The important thing is that you find the actions responsible for a healthy percentage that you can fix, and then fix them. When you do this, you can save time up to that percentage, but finding is what you need to do. The measurement is secondary.
Added: You may ask: "Don't you need to measure to find?" Consider an example. Suppose you run your program with debugging turned on, and you pause it arbitrarily, and you see it in the process of closing the log file. You continue this, and then pause it again and see the same thing. Itโs good that the gross โdimensionโ says that he spends 100% of his time on this. Naturally, the time spent on this is not really 100%, but whatever it is, it is big, and you found it. So maybe you donโt need to open / close the file often or something like that. Typically, more samples are required, but not too many.
source share