"So what's happening is this - every second you take the pulse of VS, and if at that particular instant in time, it's doing anything that takes longer than 2 ms, then you're counting the entire second as being hung. I don't think that's really fair."David Berg said:Joshua,
I just saw your post and looked at your code. It's an interesting way to measure performance, but I think you're unfairly assuming that any non-success code is due to a hang situation; however, it could also be due to a timeout, which you've set to only 2ms.
So what's happening is this - every second you take the pulse of VS, and if at that particular instant in time, it's doing anything that takes longer than 2 ms, then you're counting the entire second as being hung. I don't think that's really fair.
As a general rule of thumb, I tell people that it's okay to hang the UI thread for up to 100 ms during typing (although I prefer they keep it to under 50ms) and up to 4000 ms when displaying a dialog box (although I prefer they keep it well under 2000 ms).
Of course, I'm not saying that VS doesn't have some performance issues that we need to address, just that I don't think they're as bad as your program implies.
If you'd like to discuss the issue further, you can e-mail me at DevPerf@Microsoft.com.
Microsoft Developer Division
Performance Engineering Team
The reason is because without the sleep for 1000ms the application would consume too much CPU, which would negatively effect VS's performance even more. So instead of constantly polling for 1000ms, I choose to check at intervals. you can spread out the timing even more, its still sluggish.
Thinking about it a little more, a better way might be to post a message, then sleep for a second and see if the message was processed.
I guess the point wasnt really to have perfect profiling code, rather to point out that profiling UI is an easy way to quantify perceived performance. Its important because if a developer loses their train of thought it costs the company money.