A code profiler is a software tool, implemented as a DLL, which is called by the common language runtime during the execution of an image. The profiler must implement the ICorProfilerCallback interface, which the common language runtime calls to notify the profiler when specific events occur. The profiler receives notifications whenever a function is entered or exited, an assembly is loaded or unloaded, a thread has been created or destroyed, and when other events occur that are of interest to the programmer. By gathering statistics on these events, a profiler can build a comprehensive picture of which routines used the most CPU time, when garbage collections occurred, if exceptions were thrown, and so on.
The common language runtime can connect a profiler to a process during startup or attach it to a running process.