ANTS Profiler box shot

ANTS Profiler

How ANTS Profiler profiles inlined code

Many developers are familiar with the way in which a compiler can optimize code when it is compiled. One of the better-known methods of optimization is called "inlining." This is the process in which small methods are incorporated into larger methods because the size of the code makes it more practical to place the actual code into a parent method, rather than simply holding a pointer to it.

For instance, if a parent method calls a child method whose compiled code is no longer than 32 bytes, space is gained by inserting the whole method into the parent method, because it is no larger than the pointer to the original method. There is quite a performance gain to be had, since the computer no longer has to "jump" to a different address in memory to find the method and execute it.

The Just-in-time compiler in .NET has the same functionality. This, however, interferes with gathering statistics about the methods that have been run, because inlining effectively causes the smaller methods to cease to exist. Without inlining, however, an application's behavior may change so considerably that code profiling it would not reflect its performance in the real world. ANTS Profiler allows you to profile inlined code by making a few compromises, as demonstrated in the video below.