An application can be profiled in several ways. dotTrace Performance provides three profiling methods:
Sampling is the fastest and the least precise mode. This is a way of profiling when dotTrace basically grabs current call stacks on all threads once in a while. The output snapshot reflects statistics for the observed call stacks. In this mode the number of calls isn't available and times are approximate. Accuracy cannot be more than the sampling frequency which is several hundred hertz.
Tracing is slower, but more precise than Sampling. This is a way of profiling when profiler gets notifications from CLR when a method is entered and left . The time between these two notifications is taken as the execution time of the method. In this mode you can learn precise timing information and the number of calls on the method level.
Line-by-line is the slowest and the most precise mode. This is a way of profiling when dotTrace collects timing information for every statement in methods. This way of profiling lets you collect the most detailed information on methods that perform significant work. You can specify exactly which methods you want to profile or profile all methods for which dotTrace Performance is able to locate symbol information.
Generally, sampling profiling is much faster than tracing profiling. This allows to use sampling profiling to profile performance-sensitive interactive 3D graphics applications, computer games, and so on.
Another benefit of sampling profiling is that the overhead it imposes on the profilee process does not depend on what the profilee application does. The overhead of tracing profiling directly depends on the number of method calls that the profilee process makes. However, the number of method calls doesn't make any difference during sampling profiling.
The main disadvantage of sampling profiling is lower accuracy compared to tracing profiling. The accuracy of sampling profiling is limited by the thread quantum of a particular OS (~10 ms under Windows). Also, since sampling profiling does not receive notifications about entering a method, it can't measure the number of times the method was entered. Since sampling profiling gets call stacks with a certain timeout (typically once every quantum), it can possibly miss an occurrence of some very fast function being called.
Line-by-line profiling is the most accurate method since it provides exact timing information on the statement level. Compared to sampling and tracing profiling, this method imposes the greatest overhead.