VS2010 profiler : is it possible to profile one specific method?

rekna picture rekna · May 3, 2010 · Viewed 13.5k times · Source

Possibly some methods to turn on and turn off profiling from code?

Or can you select a specific function to profile ?

Answer

Chris Schmich picture Chris Schmich · May 5, 2010

You can also use the profiler's data collection API to start and stop profiling around the methods you're interested in. See this MSDN article for a walkthrough.

The best way to use the API in this case would be to call StartProfile just before your methods execute and then call StopProfile just after. You should start profiling via the "Start With Profiling Paused" option so you don't start profiling until you hit the first call to StartProfile.

Using the data collection API will work with sampling or instrumentation.