gprof Profiling - 2022.2 English

Vitis Unified Software Platform Documentation: Embedded Software Development (UG1400)

Document ID
UG1400
Release Date
2023-01-02
Version
2022.2 English

GNU gprof provides two kinds of information that you can use to optimize the program:

  • A histogram with which you can identify the functions in the program that take up the most execution time
  • A call graph that shows what functions called which other functions, and how many times

The execution flow of the program is altered so that gprof can obtain data. Consequently, this method of profiling is considered software-intrusive. The program flow is altered in two ways:

  • To obtain histogram data, the program is periodically interrupted to obtain a sample of its program counter location. This user-defined interval is usually measured in milliseconds. The program counter location helps identify which function was being executed at that particular sample. Taking multiple samples over a long interval of a few seconds helps identify which functions execute for the longest time in the program.
  • To obtain the call graph information, the compiler annotates every function call to store the caller and callee information in a data structure.

The profiling workflow is described in the following diagram:

Figure 1. Profiling Workflow

Note: Xilinx recommends not to use garbage collector flags when you run profiling. Using garbage collector flags can cause errors.
For additional information about GNU gprof, refer to http://sourceware.org/binutils/docs-2.18/gprof/index.html .