dotTrace Web Help

dotTrace Performance installation includes a Profiling API that lets you control profiling directly from the code of the profiled application.

To use the API for profiling your applications
  1. Reference the JetBrains.Profiler.Windows.Api.dll assembly (located in the dotTrace Performance installation directory) from your project.
  2. Insert calls to methods of JetBrains.Profiler.Core.Api.PerformanceProfiler class into your code as required by your use case.
  3. Start profiling the application from within dotTrace, and select the Use profiler API check box in the Profiler Configuration dialog box.

Consider the example below:

                 class Class1
                    void A()
                        if (!JetBrains.Profiler.Core.Api.PerformanceProfiler.IsActive)
                            throw new ApplicationException("Application isn't running under the profiler");
                        bool res = false;
                        for (int n = 0; n < 8; ++n)
                            res = res || Do();

                        if (res)

Item Description
Begin() Creates an empty snapshot.
Start() Starts taking performance measurements for the application. Note that measurements are taken for all threads.
Stop() Stops taking performance measurements for the application. Current data will persist in memory so next time you start taking measurements the new data will be added to the current data.
EndSave() Stops taking performance measurements and opens a snapshot with current data in the profiler. After opening the snapshot, measurement data is reset.
EndDrop() Stops taking performance measurements and resets current measurement data.
IsActive {get;} Gets a value that indicates whether the profiler is active.