Profile application with FlameGraph

Install FlameGraph

sudo apt install -y linux-tools-$(uname -r) linux-tools-common
git clone

Compile YOUR-APP with -g and -O0 flags, then you can execute like below:

sudo time perf record -g -o YOUR-APP
sudo perf script -f -i | FlameGraph/ | FlameGraph/ > flamegraph.svg

The result is a an SVG that can be viewed on a web browser-

From this graph you can see which call-graph was taking the majority of the execution time. The x-axis is the time, so longer boxes means longer execution time on the CPU.