Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Profiling: Start/Stop from code

Is there a possibility to start/stop the visual studio (Professional 2012+) profiler from code? I know you can start it paused, but to start the profiling, you have to click on a button in the visual studio.

In my case, I would like to start it when clicking on a button in my application, which switches to a new view, and automatically stop it when the UI was loaded. I would like to see why there is such a large delay until the UI shows up.

like image 866
LionAM Avatar asked Jan 08 '15 13:01

LionAM


People also ask

Does Visual Studio code have profiler?

If you use the dotTrace extension integrated with Visual Studio, it helps you start profiling the applications from the IDE. You also can view and analyze timeline profiling results right in Visual Studio.

How do I run a performance profiler in Visual Studio?

Open the Performance Profiler by choosing Debug > Performance Profiler (or Alt + F2). For more information on using the CPU Usage or Memory usage tool in the Performance Profiler vs. the debugger-integrated tools, see Run profiling tools with or without the debugger.

How does Visual Studio analyze CPU usage?

Collect CPU usage dataSelect Debug > Performance Profiler. Under Available tools, select CPU Usage, and then select Start. After the app starts, the diagnostic session begins and displays CPU usage data. When you're finished collecting data, select Stop Collection.

How do I check the execution time in Visual Studio?

If milliseconds then in Visual Studio 2019 you can see the time between two breakpoints under Diagnostic Tools -> Events -> Duration (opens automatically in Debug mode, or use Ctrl + Alt + F2 ).


1 Answers

I've not used it before, but it seems you're looking for Profiling API.

DataCollection.StartProfile and DataCollection.StopProfile looks like the methods you're interested in.

like image 114
Sriram Sakthivel Avatar answered Sep 29 '22 17:09

Sriram Sakthivel