Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

How-To's

Profiling from the Command Line using dotTrace Performance

Did you know that you can run dotTrace Performance from the command line? Why would you want to run it from the command line? Maybe you want to share the same profiling configuration across the team? Maybe you want to run it as part of your build process? Maybe you want to run dotTrace as part of a larger testing process with other command line tools?

There are lots of reasons why you might want to run dotTrace Performance from the command line. Let’s look at how we can do exactly this.

Profiling from the command line is divided into two steps. First we create a configuration file that specifies the options we want to use. Next we launch dotTrace Performance using that profiling configuration file.

Creating a profiling configuration file

  1. To create a profiling configuration file, open a command prompt and change to the dotTrace installation directory:
    cd c:Program Files (x86)JetBrainsdotTracev5.2Bin
  2. Run Configuration2Xml.exe with the full path of the configuration file that you want to create:
    .Configuration2Xml.exe <ConfigFilePath>
    For example:
    .Configuration2Xml.exe c:codeProfilingConfiguration.xml
    N.B. Running Configuration2Xml.exe with an existing profiling configuration file will edit the file rather than overwriting it.
  3. The Profile Application dialog will open. Select the type of application that you want to profile and click OK:
    Profile Application
  4. The Profiler Configuration dialog will open. Select the profiler options that you want to use and click Save:
    dotTrace Profiler Configuration
  5. Configuration2Xml.exe will create the specified profiling configuration XML file.
    dotTrace XML configuration file

Profiling

  1. To start profiling, run dotTraceProfiler.exe with the profiling configuration file:
    .dotTraceProfiler.exe <ConfigFilePath>
    For example:
    .dotTraceProfiler.exe c:codeProfilingConfiguration.xml
  2. Once the application exits, a DTP file will be written in the current working directory, which can be opened and analyzed in dotTrace Performance.

For additional control of profiling, dotTraceProfiler.exe has a number of optional command line arguments:

  • /showcontroller: Open the profile controller dialog where you can start/stop profiling, capture snapshots, and detach/kill the profiled process.
    dotTrace controller
  • /output=<OutputPath>: Specify the file name and/or directory where snapshots should be saved.
  • /rawformat: Use an uncompressed snapshot format for faster processing and saving at the expense of increased file size.

dotTrace Performance can easily be orchestrated from the command line and integrated into your development process. Profile with pleasure!

image description