Getting Started with Performance Profiling

Skip to end of metadata
Go to start of metadata

dotTrace lets you profile different kinds of .NET applications, including applications based on .NET Framework up to version 4.5.x, Silverlight 4 and 5, and even Windows Store applications. It offers a convenient way to uncover potential performance issues in your applications and find bottlenecks in your code.

dotTrace provides two methods for profiling your apps: performance and timeline. Although both methods are quite interchangeable, there are tasks where one of the methods will do better. For example, the performance profiling method described in this document is better suited for more straightforward "What is the slowest method" tasks. At the same time, the timeline profiling method that collects temporal call stack data shows its best on issues where the order of events does matter: UI freezes, sync delays, excessive garbage collections, and so on. For details on how to use timeline profiling, refer to this tutorial.

There are two ways to start profiling your application: you can either launch dotTrace as a standalone tool or from Visual Studio. At the time of this writing, dotTrace integrates into four versions of Visual Studio: 2010, 2012, 2013, and 2015 Preview.

Standalone. This mode is ideal for applications where the original project or source code is not available or when you want to run dotTrace without having Visual Studio installed or launched.

  1. Start dotTrace from the Windows Start menu. 
    Running_dotTrace_1
    This will run the dotTrace Home window.

From Visual Studio. This mode is ideal when you want to profile an existing project running under Visual Studio. 

  1. Start Visual Studio
  2. Open a solution.
  3. On the menu bar, choose ReSharper | Profile | Profile Startup Configuration Performance Profiling for the startup project opened in Visual Studio.

resharper_menu_upd

Profiling an application

In case, you profile startup project from Visual Studio, dotTrace will automatically detect app type.

If you ran dotTrace as a standalone app*, the next step is to select the type of the application you are going to profile. This is done on the central panel.
In this example we'll profile a web application hosted in IIS Express.

The profiling options on the right panel let you fine-tune your profiling experience. Depending on the selected application type, different sets of profiling options can be displayed.

One of the important settings that affect profiling speed and accuracy is Profiling type which gives you three options:

  • Sampling profiling is the fastest method. It accurately measures calls time, but doesn't get data on number of calls. This profiling type allows you to quickly get a general idea of the application's performance.
  • Tracing profiling is slower, but more precise when it comes to measurement of calls number. This mode can be used to evaluate algorithms complexity.
  • Line-by-line profiling is the slowest method that measures each line of code. The line-by-line profiling makes sense only when you already know what function causes issues and want to analyze each line of it.
  • Timeline is used to perform timeline profiling of your app. Read about it in a separate tutorial.

Click Run to start profiling. dotTrace will attach to your application's process and start collecting performance data. The Controller window is also displayed.

Get a snapshot

Once you feel that all information you need has been collected, click Get Snapshot'n'Wait. This will capture the data and display it in a snapshot window.

Snapshots can be stored and compared, so you can see how code changes affected your application performance.

Analyzing snapshot data

To help you analyze the results of performance profiling dotTrace offers a special Performance Viewer application. It provides multiple views for analyzing snapshot information. The Threads Tree view shown by default allows you to drill down in the snapshot information based on the threads in your application.

The Call Tree view organizes data based on method calls, Plain List shows all the different methods that have been called, what other methods they have called, how long these calls took and so on.

The Hot Spots view shows methods that have the highest own time in your application. In other words: methods that dotTrace Performance identified as a potential performance issue.

Note that whenever you select a method, Performance Viewer shows you the actual code for this method based on information provided by your application's debugging symbols. If no source code is available, Performance Viewer will try to decompile the method from the assembly.

Once you've mastered these basics, learn the various techniques in analyzing profiler data. Performance Viewer includes great features like remote profiling, navigating through method calls, filtering and folding and estimating performance gains. All of them are described on the dotTrace documentation page.

Finally, don't forget to check out JetBrains TV and JetBrains .NET Tools blog for more tips and tricks with dotTrace profilers. You might also like JetBrains on Facebook or follow dotTrace on twitter.

  • No labels