dotTrace 2016.1 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. Do nothing // (do not throw exceptions, etc.) if IsActive is false if (PerformanceProfiler.IsActive) { PerformanceProfiler.Begin(); PerformanceProfiler.Start(); } // 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. Do nothing // (do not throw exceptions, etc.) if IsActive is false if (TimelineProfiler.IsActive) { TimelineProfiler.Begin(); } // 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(); } // and so on ...

See Also

Reference:

Last modified: 19 August 2016