c# - Benchmarking code precisely -
I need to measure the performance of my code with the maximum possible precision I
Currently I use I am doing:
- Stopwatch for measuring from time to time - Set process intimacy to use all CPU cores - Set maximum thread preference - Display warm-up before measuring - 1000 times Test and calculate average
However, I run benchmark C 1% difference between the maximum) I how a measure to make more precise the measurement?
This may be obvious, but your CPU is not dedicated to your single process, Also works for many things I
In addition, the behavior of memory usage, HDD usage and GC behavior can vary between hanging. Your computations may require virtual memory, which is much slower than RAM access. And so on ...
About GC, you can try to play with various settings of "GCSettings.LatencyMode" to see if anything changes it (for example See).
The same session, stopwatch on the same computer is quite accurate: If the duration is different between execution, then it is probably not due to the lack of accuracy in the measurement, because this process does not take at all ... Obviously, each of your tests should be "repetitioned" at least a few hundred milliseconds, the stopwatch will never be able to measure a period in nanosecond ...
and 1% difference at all Not surprisingly Is In.
Comments
Post a Comment