ANTS Profiler 3   

Understanding the Profiling Results

See Also

This topic provides information that may help you to understand your profiling results.

Hit counts

In some circumstances, lines of code may be executed more often than you expect. This is most often the case with loops. You might think that the following line of C# is executed 100 times:

for(int i = 0; i < 100; i++)

It is, in fact, executed 202 times. This is because there is an initial variable assignment. The value of i is then checked 100 times successfully, incremented 100 times, and then checked again. This is more obvious if you write, and profile the line of code as follows:

	
for(
int i = 0; // executed once
i < 100; // executed 101 times
i++ // executed 100 times
)

In some circumstances, methods may be executed less than you expect. This can happen when a method is always inlined by the .NET Framework runtime; if you are profiling in fast mode and you have built your application with the optimization option enabled, the method is indicated by a fully-shaded gray bar in the Source code panel.

Note that if you have disabled the profiler when you profile performance in detailed mode, sometimes ANTS Profiler records hit counts as zero. This is a known issue.

Timings

The total execution time for a line can sometimes be greater than the total execution time for a method because method-level timings do not include calls to child methods.

Note that in 64-bit applications, the total execution time for a line that calls Thread.Sleep is greater than the total execution time for a method call to System.Threading.Thread.Sleep. For example, if you call System.Threading.Thread.Sleep(1000), the line timing is 1 second as the CLR pauses the thread for 1 second but the method-level timing is 0 seconds as the method call returns immediately. This is the expected behavior.

If you are using fast mode, the timings are not always displayed where you would expect. For example, when ANTS Profiler profiles a constructor, the timings are displayed next to the line of code that the .NET CLR considers as the first line of the constructor body instead of next to the constructor call. This can result in timings being placed next to lines that are outside of any methods as the source code does not map precisely to the compiled code.

To find out the average, maximum, or minimum time that a method takes to execute, you can add the Average time (sec.), Average time with children (sec.), Maximum time (sec.), or Minimum time (sec.) columns to the All methods panel. These columns are not displayed by default.

Source code

ANTS Profiler shows source code only when you are profiling a debug build of your application. ANTS Profiler reads the .pdb (Program Debug Database) files for your application so that it can locate the source code on your computer. The .pdb files must be in the same folder as the executable file or .dll files.

If you select Only .NET methods that have source code in the Choose what code to profile page of the Profiler Project Wizard, and there is no .pdb file, ANTS Profiler displays a message to inform you that no .NET methods have been profiled.

If you are profiling an ASP.NET Web application, debug must be set to true in the web.config file for the .pdb files to be included in the build.

 

 

 


© Red Gate Software Ltd 2007. All Rights Reserved.