The perf tool can be used to collect profiles on per-thread, per-process and per-cpu basis.
There are several commands associated with sampling:
record
report
annotate
You must first collect the samples using perf record. This generates an output file called perf.data. That file can then be analyzed, possibly on another machine, using the perf report and perf annotate commands.
Collecting Samples
Different from perf stat, perf record is a sampling system. And there are two modes of sampling period:
Mode
Example
Description
-c
-c 2000
to collect a sample every 2000 occurrences of event
-F
-F 250
sampling at 250HZ
By default, -F 1000 is used.
Also another useful option is "-g", this will aggregate child functions which may help to give you a better understanding.
Analysis with perf report
perf report will read perf.data by default and generates a concise execution profile.