Documentation.NET Profiler HelpCPU profilingRecording CPU information. Sampling and tracing.
previous      content      next
Recording CPU information. Sampling and tracing.

First, connect to the profiled application.

CPU profiling controls in the toolbar

The toolbar contains the following CPU profiling controls:

CPU usage graph

The "CPU" tab shows live CPU consumption statistics.

A very useful and unique feature of this graph is that the telemetry information is remembered inside the profiler agent. This allows you to connect to the profiled application on demand and discover how the application behaved in the past.

CPU profiling

  • Start measuring

    To begin obtaining profiling results, start CPU measuring when your application requires it.

    You can choose either of two available measurement modes: sampling or tracing.

    Time

    Invocation Count

    Overhead

    Accuracy

    Required .NET Framework version

    Sampling

    Available

    Not available

    Negligible

    Average

    .NET Framework 2.0 or newer

    Tracing

    Available

    Available

    Depends on current filter set

    High

    .NET Framework 1.1 or newer

    Sampling

    When sampling is used, the profiler periodically queries stacks of running threads to estimate the slowest parts of the code. No method invocation counts are available, only CPU time.

    Sampling is typically the best option when your goal is to locate and discover performance bottlenecks. With sampling, the profiler adds virtually no overhead to the profiled application. Note: Sampling is available only if your application runs .NET Framework 2.0 or newer, because .NET Framework 1.1 does not provide appropriate means for querying stacks. With .NET Framework 1.1, only tracing is available.

    Tracing

    When tracing, the profiler watches all method invocation for recording thread CPU time spent inside each profiled method. Both times and invocation counts are available.

    Although tracing provides more information, it has its drawbacks. First, it may noticeably slow down the profiled application, because profiler-specific support code is executed on each method entrance/exit. The greater the number of method invocations in the profiled application, the lower its speed when tracing is turned on. The second drawback is that, since this mode affects the execution speed of the profiled application, the CPU times recorded in this mode may be less adequate than times recorded with sampling. Please use this mode only if you really need method invocation counts.

    After selecting the profiling options, start profiling as follows:

  • Live results

    When profiling is started, the bottom table on the "CPU" tab shows a top-down call tree with calls with all threads merged.

    In case of CPU tracing, both method invocation counts and times are shown. Invocation counts are not cumulative. In case of CPU sampling, method times are shown.

    CPU telemetry provides only basic information. To perform comprehensive analysis, use "Capture performance snapshot".

  • Finish measuring and get the results

    When the task you intended to profile has finished (or has performed for a sufficient amount of time), capture a CPU snapshot with all the recorded information.

    When this is done from the profiler UI, you can open the results for immediate analysis.

    Further topics in this section describe the profiler's UI for analyzing CPU profiling results.

You can start and stop CPU profiling during the execution of your application as many times as you want. When CPU profiling is not running, YourKit Profiler for .NET adds no performance overhead to application(s) being profiled.

Note: In some cases, it also may be useful to launch the application with CPU profiling already started and/or automatically capture CPU snapshot on exit of the profiled application.

previous      content      next