Possibly some methods to turn on and turn off profiling from code?
Or can you select a specific function to profile ?
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.