Jump to navigation Jump to search


perf tool

  • Install
apt-get install linux-perf
  • Produce profile data

Compile with '-fno-omit-frame-pointer' options as CFLAGS. An alternative exists, using the '--call-graph dwarf' option, however it apparently generates a lot of more disk data. To know more about such option, take a look at the link and use 'perf help record' to show all the options.

For instance, use

-Og -g3 -fno-omit-frame-pointer

or the more gdb specific

-Og -ggdb3 -fno-omit-frame-pointer

There are a lot of event that can be monitored, and they can be specified using the -e option. The default event is just 'cycles' (or 'cycles:pp' apparently), but the option accept multiple event types separated by a comma, like '-e cpu-clock,faults' for instance.

perf record -q -e cycles -g --call-graph fp -- ./COMMAND ARG1 ARG2 ... ARGN
  • Visualization
perf report --stdio -g none --sort comm,dso      # load per module
perf report --stdio -g none                      # load per function
perf report --stdio -g graph                     # call chains
perf report -g graph -s period,comm,dso,symbol   # TUI interface

Example of output of STSM program:

-   92.18%     0.00%  stsm     stsm                  [.] main
   - main
      - 91.77% STSM::run
         + 56.86% STSM::generateCandidates
         - 25.22% STSM::detectBlocksOfAllSolidSequences
            + 23.42% STSM::detectSolidSequenceBlocksFromSolidSequence
              0.81% Segment::unify
         + 5.25% STSM::updateKernelsOfAllCandidates
           1.80% RangedSequence::range
         + 1.45% STSM::updateMatchingPositions
           0.99% Segment::intersects
+   92.18%     0.00%  stsm          [.] __libc_start_main
+   92.18%     0.00%  stsm     [unknown]             [k] 0x4d96258d4c544155
+   91.77%     0.00%  stsm     stsm                  [.] STSM::run
+   56.86%     6.74%  stsm     stsm                  [.] STSM::generateCandidates
+   49.99%    49.99%  stsm     stsm                  [.] Segment::intersects
+   25.22%     0.00%  stsm     stsm                  [.] STSM::detectBlocksOfAllSolidSequences
  • GUI

There is a script to generate graphs.


apt-get install python3 graphviz

Test it after using perf record command:

perf script | c++filt | -f perf | dot -Tpng -o output.png


valgrind tool

valgrind --tool=callgrind --callgrind-out-file=I100_Ooriginal_S26_FS10_FB05_MS0.grind ./stsm 100_sax-26_sample-46x951.csv I100_Ooriginal_S26_FS10_FB05_MS0.js\
onn I100_Ooriginal_S26_FS10_FB05_MS0.log 10 05
qcachegrind I100_Ooriginal_S26_FS10_FB05_MS0.grind

gprof tool

It is included in binutils package. To use:

1) compile and link sources using -pg flag

2) run the compiled source, it will generate a gmon.out file

3) use gprof to evaluate

  • Example
cc -Wall -pg main.c -o a.out
gprof ./a.out gmon.out > report.txt