Being a CLR performance dev, it seems that CLR profiler will be a very useful. So now I'm trying to understand it inside out, and may be even make some improvement to it.
Here are the steps I'm taking:
Performance Wizard (Visual Studio 2010 Sample Profile) shows the following summary page:
It shows that most of the time is spending on loading the profile, almost half of it is on reading integers.
Let's deal with this later, and focus on a simpler problem. If you play with the profiler's analysis, you will find that the following code updaing progress bar/calling DoEvents is consuming 8.4% of CPU.
The problem with ths code is that it's updatng progress bar and calling Application.DoEvents too often. To be more specific, it's updating every 1,000 lines. For the 157 Mb profile, there are actually 11 million lines, so the code within the 2nd if clause is executed 11,000 times.
It we limit the numbers of updates to 512 times, 8.4% is now reduced to 0.6%:
Now CLRProfiler is little bit faster.
Let's look at top 10 most costly functions (sorted by exclusive samles) before and after the change:
Not very professional perf measurements, but you can clearly see we knocked two WinForm functions out of the top 10 contributors.