dotTrace Web Help

API Usage Examples

To use the API for performance profiling:

  1. Download and unpack the profiling SDK.
  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() { if (PerformanceProfiler.IsActive) { PerformanceProfiler.Begin(); PerformanceProfiler.Start(); } // Here goes method code if (PerformanceProfiler.IsActive) { PerformanceProfiler.Stop(); PerformanceProfiler.EndSave(); } }
  4. Start profiling the application from within dotTrace, 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.
  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() { if (TimelineProfiler.IsActive) { TimelineProfiler.Begin(); } // Here goes method code if (TimelineProfiler.IsActive) { TimelineProfiler.EndSave(); } }
  4. Start profiling the application from within dotTrace, and select the Use profiler API check box in profiler options.

To use the API in self-profiling applications:

  1. Download and unpack the profiling SDK.
  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, TempPath = Path.GetTempPath(), SaveDir = "C:\\Temp", RedistDir = "C:\\ProfilerSDK", ProfilingType = ProfilingType.Performance, ListFile = "snapshot_list.xml" });
  5. Insert calls to methods of the PerformanceProfiler or TimelineProfiler class into your code as required by your use case.

See Also

Reference:

Last modified: 5 December 2014
comments powered by Disqus