How to pause & resume profiling when using SelfAttach.Attach API
Using the following console program, I expected to see no mention of M1 or M4 in the profiling results (becase profiling should have been paused when those methods were called). However, M1, M2, M3, M4 and M4 were all shown as taking about 500ms to execute.
Is it possible to pause the profiler when using SelfAttach.Attach? If it's not possible, how do I turn this into a feature request?
The reason I'm trying to do this, is because I've deteced that my UI thread is blocked for too long so I want to turn on the profiler to recored what's happening. When the UI threads is unblocked again, I want to pause profiling until next time I detect that it's blocked.
var config = new OpenProfilingConfig()
{
ProfilingControlKind = ProfilingControlKind.API,
RedistPath = @"C:\Program Files (x86)\JetBrains\dotTrace\Profiler SDK v5\Redist"
};
SelfAttach.Attach(config);
ProfilingControl.StartPaused();
// Give profiler a chance to setup
Console.WriteLine("Press Enter when the profiler is ready");
Console.ReadLine();
M1();
ProfilingControl.Resume();
M2();
M3();
ProfilingControl.Pause();
M4();
ProfilingControl.Resume();
M5();
ProfilingControl.Stop();
ProfilingControl.Detach();
Console.WriteLine("Press Enter to exit");
Console.ReadLine();
Please sign in to leave a comment.
Wilka, I'm copying my email here - in case if anyone else faces the same problem.
Please install new version of SDK (http://download.jetbrains.com/dottrace/dotTraceProfilingSDK.msi); here's an example of how it can be used now:
And that's how the snapshot will look like: