views:

133

answers:

3

Hello everyone,

If I use instrumentation model as described here to profile .Net application performance, it means the profile tool will change the executable code of the to be profiled executable to insert performance measure code? So my original executable code is modified?

http://msdn.microsoft.com/en-us/library/ms242753(VS.80).aspx

regards, George

+1  A: 

Yes; the instrumented code is different to uninstrumented code. And this means you have to be slightly careful with the results - but most profilers do a reasonable job of drawing your focus to the important bits. I've never had much luck with the sampling option - instrumentation has often been useful, though. Personally, I like the jetBrains offering.

Marc Gravell
Cool, Marc! Two more comments,1. Just confirm with you that instrumentation mode will actually change original code or executable?2. I found jetBrains is not free and and advantages compared with built-in profiler in VSTS?
George2
Another comment, in sampling model, any ways to including the time when thread is wait status? If I remember correctly, sampling model does not calculate time in wait thread? So if my application performance bottleneck is in some thread always wait, I can never know from sampling model?
George2
A: 

Sampling mode is when you what to know hot areas in your code, it doesn't modify your code it will just sample the current callstack of of all running threads. If your threads are contently sleeping or wait for a resource (mutex, event, etc) then it will count as a hot area. You want to use this mode to measure load.
Instrumnation mode (tracing) will measure how much time (in cycles) are spend in each method.
It needs to instrument your code (using the debug symbols) but it will exclude at the end the overhead that it put on the system. You want to use this mode to measure an single process.

Shay Erlichmen
A: 

Yes, when instrumenting, the profiler is going to modify your code with additional instructions to gather and track the necessary performance data. You'd never want to distribute an instrumented version of your assemblies, and you wouldn't want to use instrumented assemblies for debugging purposes (as critical sections / race conditions / etc could certainly behave differently given the additional instrumentation).

That being said, instrumentation can be very valuable for the goals profiling is meant to address. By gathering actual data and isolating expensive operations, optimization efforts can be focused appropriately and the results can be measured accurately - avoiding wasted time, increased complexity, reduced maintanability, and all the other problems associated with premature optimization.

allgeek