I have an GUI application that takes a while to load all its plugins, before it is ready to be used by the user.
I want to write a C# program that would measure the time taken for this application to start up. I thought the Process.WaitForInputIdle() method would do the trick, but it doesn't. It exits as soon as the process is started.
What I have now is this:
DateTime startTime = DateTime.Now;
Process myAppUnderTest = Process.Start("C:\\Program Files\\My App\app_under_test.ext");
myAppUnderTest.WaitForInputIdle(); //Wait until the application is idle.
DateTime endTime = DateTime.Now;
int elapsedTimeInSecs = endTime.Subtract(startTime).Seconds;
Console.WriteLine("Start up time (sec): {0}", elapsedTimeInSecs);
How can I get the start up time that I intend?
I say it's very difficult.
How do you classify an application loaded and ready? If there is a way (which I don't think so) then it would be easy.
But if the app you are loading signals you in certain way (IPC/files/network), then you can capture that signal and say the app is loaded. In that case, you can use a timer/stopwatch/performance counter.
If you can modify the to be timed app, then you can achieve in various ways. If its external to you, I doubt there is any easy way.