I'm not quite sure which part of the
method is consuming this much time. So
I'd like to measure it
Things that take much longer than they should are very easy to find.
For example, if it's taking 10 times longer than it should, that means 90% of the time it is doing something not needed. So, if you run it under the IDE and pause it, the chance you will catch it in the act is 90%.
Just look at the call stack, because you know the problem is somewhere on it.
If you're not sure you've caught it, try it several times. The problem will appear on multiple samples.
Typical things I've found in .net app startup:
- Looking up resources such as international strings, needlessly.
- Walking notification trees in data structures, to a needless extent.
What you find will probably be different, but you will find it.
This is a low-tech but effective method. It works whether the time is spent in CPU or in I/O. It does not measure the problem very precisely, but it does locate it very precisely.
(Check the last paragraph of this post.)