The Telerik JustTrace's Profiler API allows direct integration between your source code and the profiling sessions.
The JustTrace's Profiler API is separated in two controller classes, both coming from the same namespace
(Telerik.JustTrace.Profiler.Api), the MemoryController and the
PerformanceController class. The Memory Controller finds its place for optimizing the
memory usage of your program or/and identifying memory leaks in it. The Performance Controller on the other hand
is used for measuring how fast certain operations actually are.
Usage
Important |
---|
You need to have JustTrace installed, in order to use the profiler API |
First, open the project you want to profile inside Visual Studio and refer the Telerik.JustTrace.Profiler.Api.DLL
in it. You will find that DLL in the JustTrace's install folder, under Libraries (by default:
"C:\Program Files (x86)\Telerik\JustTrace\Libraries\Telerik.JustTrace.Profiler.Api.dll").
After this, you will need to import the API to the corresponding namespaces
(using Telerik.JustTrace.Profiler.Api;).
Continue by adding the profiler commands from the JustTrace's Profiler API to your source code. Below,
you will find a complete API reference about what can be used and where to put it.
Setup your project for profiling within Visual Studio, or the JustTrace standalone client and run it with enabled profiler.
While running, the execution of the application will go through the JustTrace Profiler API commands and will perform the needed actions
for you.
Note |
---|
For performance profiling it is recommended to start the profiling sessions with the Disabled at Start option.
This will avoid the gathering of unnecessary information, as the Profiler API will enable the profiler from the code when needed.
|
Finally, examine the results in the JustTrace Session window within Visual Studio, or the standalone client.
Memory Controller
The Memory Controller allows the profiled applications to control the JustTrace Memory profiler. Using it, you will be
able to get snapshots in an exact moment of your code execution.
API References:
CopyC#
namespace Telerik.JustTrace.Profiler.Api
{
public static class MemoryController
{
public static bool IsProfilerAttached { get; }
public static void GetSnapshot(bool throwOnError = true) { }
}
}
Sample code from the Demo.RayTracer project:
CopyC#
private void StopRender()
{
MemoryController.GetSnapshot(true);
}
The above code shows how you can get a memory snapshot in an exact moment of your application's execution. In this case, we are getting
a snapshot right after the rendering process has finished. This will show us if the memory is released as expected or there are leaks.
Performance Controller
The Performance Controller controls the JustTrace's Sampling or Tracing profiler (this can be controlled from the
JustTrace's UI and depends on its current state). Currently, the controller only enables, or disables the profilers allowing you to profile
an exact portion of your code with extreme accuracy.
API References:
CopyC#
namespace Telerik.JustTrace.Profiler.Api
{
public static class PerformanceController
{
public static bool IsProfilerAttached { get; }
public static bool IsProfilerEnabled { get; set; }
public static bool IsProfilerEnabledNoThrow { get; set; }
}
}
Sample code from the Demo.RayTracer project:
CopyC#
private void StartRender(int threadsCount)
{
PerformanceController.IsProfilerEnabled = true;
PerformanceController.IsProfilerEnabled = false;
}
The above example shows how the performance profiler can be enabled only for certain piece(s) of your code. This eliminates the unnecessary
parts, so that JustTrace can visualize only this and you can see the actual measurement.