views:

26

answers:

1

I run my project within VS and from time to time I run it with VS profiler.

The question is how to detect the second case?

The reason: I would like to trigger GUI events from program when profiling -- this way I would avoid manually clicking on widgets every time I do profiling. I am explaining this, because maybe is smarter way then detecting profiler and adding some "ifs".

+1  A: 

It sounds like you are trying to automate your application when it is being run under the profiler. The goal being to automate a certain set of actions you are interested in profiling. If so ...

I don't know of a way to detect off hand if a process is running under the profiler. Any such detection would likely be flaky.

A more reliable way to do this would be to simply add a parameter to your application which instructs it to automate the scenario. Then simply pass this parameter to the application when you are launching under the profiler (most allow you to pass options to the process). This will greatly simplify the scenario.

An even better solution would be to write a second program whose sole purpose is to drive the application. This removes the test only code from your production application.

JaredPar
Great, thank you very much for help -- the second approach is overkill for me (at least at this stage). Currently the "top priority" is automatically quiting just after starting the program ;-D So I could easily track the loading performance and quiting.
macias