Profiling (computer programming)

Profilers use a wide variety of techniques to collect data, including hardware interrupts, code instrumentation, instruction set simulation, operating system hooks, and performance counters.

Compiler writers often use such tools to find out how well their instruction scheduling or branch prediction algorithm is performing...The output of a profiler may be: A profiler can be applied to an individual method or at the scale of a module or program, to identify performance bottlenecks by making long-running code obvious.

[1] A profiler can be used to understand code from a timing point of view, with the objective of optimizing it to handle various runtime conditions[2] or various loads.

[6] Performance-analysis tools existed on IBM/360 and IBM/370 platforms from the early 1970s, usually based on timer interrupts which recorded the program status word (PSW) at set timer-intervals to detect "hot spots" in executing code.

[8] In 1994, Amitabh Srivastava and Alan Eustace of Digital Equipment Corporation published a paper describing ATOM[9] (Analysis Tools with OM).

Profilers interrupt program execution to collect information, which may result in a limited resolution in the time measurements, which should be taken with a grain of salt.

A sampling profiler probes the target program's call stack at regular intervals using operating system interrupts.

Sampling profiles are typically less numerically accurate and specific, but allow the target program to run at near full speed.

Dedicated hardware can go beyond this: ARM Cortex-M3 and some recent MIPS processors JTAG interface have a PCSAMPLE register, which samples the program counter in a truly undetectable manner, allowing non-intrusive collection of a flat profile.

The effect will depend on what information is being collected, on the level of timing details reported, and on whether basic block profiling is used in conjunction with instrumentation.

Graphical output of the CodeAnalyst profiler