dotTrace 2017.2 Help

API Usage Examples

To use the API for performance profiling:

  1. Download and unpack the profiling SDK. If your domain policy is to treat the files downloaded from the Internet as unsafe, unblock the zip archive using the Unblock button in file properties.
  2. Reference the JetBrains.Profiler.Windows.Api assembly from the JetBrains.Profiler.Windows.Api.dll file located in the main directory of the dotTrace SDK.
  3. Insert calls to methods of the PerformanceProfiler class into your code as required by your use case. Consider the example below:
    private void SomeMethod() { // check IsActive only once if (PerformanceProfiler.IsActive) { PerformanceProfiler.Begin(); PerformanceProfiler.Start(); } else MessageBox.Show("Profiler is not active"); // Here goes method code PerformanceProfiler.Stop(); PerformanceProfiler.EndSave(); }
  4. Start profiling the application from within dotTrace or Visual Studio, and select the Use profiler API check box in profiler options. *

To use the API for timeline profiling:

  1. Download and unpack the profiling SDK. If your domain policy is to treat the files downloaded from the Internet as unsafe, unblock the zip archive using the Unblock button in file properties.
  2. Reference the JetBrains.Profiler.Windows.Api assembly from the JetBrains.Profiler.Windows.Api.dll file located in the main directory of the dotTrace SDK.
  3. Insert calls to methods of the TimelineProfiler class into your code as required by your use case. Consider the example below:
    private void SomeMethod() { // check IsActive only once if (TimelineProfiler.IsActive) TimelineProfiler.Begin(); else MessageBox.Show("Profiler is not active"); // Here goes method code TimelineProfiler.EndSave(); }
  4. Start profiling the application from within dotTrace or Visual Studio, and select the Use profiler API check box in profiler options. *

To use the API in self-profiled applications:

  1. Download and unpack the profiling SDK. If your domain policy is to treat the files downloaded from the Internet as unsafe, unblock the zip archive using the Unblock button in file properties.
  2. Reference the JetBrains.Profiler.Windows.SelfApi assembly from the JetBrains.Profiler.Windows.SelfApi.dll file located in the main directory of the dotTrace SDK.
  3. Supply your app with the SDK redistributables.
  4. Initiate self-profiling somewhere in your app using the SelfAttach class. For example:
    SelfAttach.Attach(new SaveSnapshotProfilingConfig() { ProfilingControlKind = ProfilingControlKind.Api, SaveDir = "C:\\Temp", RedistDir = "C:\\ProfilerSDK", ProfilingType = ProfilingType.Performance, ListFile = "C:\\snapshot_list.xml" // the file is created automatically during profiling });
  5. Insert calls to methods of the PerformanceProfiler or TimelineProfiler class into your code as required by your use case. If you start profiling right after the self-profiling initialization, add a short wait (the SelfAttach API requires some time to start):
    while (SelfAttach.State != SelfApiState.Active) Thread.Sleep(250); // wait until API starts if (PerformanceProfiler.IsActive) { PerformanceProfiler.Begin(); PerformanceProfiler.Start(); } else throw new Exception(); // and so on ...
Last modified: 14 December 2017

See Also

Reference: