Runtime Profiling
Profiling is a non-intrusive method of measuring the performance of the functions in a program. Profilers work by sampling a program's current execution address at frequent intervals (hundreds of times in a second) and making a log of which functions happened to be executing at the time. This is a statistical sampling approach that has reasonable accuracy. Sometimes, though, the results can be confusing as a program may spend a lot of time on functions that are a part of the operating system kernel. The most popular runtime profiling tool on Linux is perf. In the next section, we'll make use of perf to profile our program.
Exercise 3: Using perf to Profile Programs
perf can be installed on Ubuntu as follows:
apt-get install linux-tools-common linux-tools-generic
To get familiar with the basics of using perf, we'll profile and analyze the program from the previous exercise with the help of the perf tool. Perform the following steps to complete this exercise:
-
...