State
perf stat is the command with lowest overhead, since it just counting events in-kernel context.
Basic usage
The basic usage for perf stat is "perf stat command". This will counting events for the command.
Repeated measurement
perf could run test multiple times and get the standard deviation from the mean.
Specify target
By default, perf counts all threads of the process, while you could specify the target with options.
Option
Example
Description
-i
child task do not inherit counters
-p
-p pid
stat on existing process id
-t
-t tid
stat on existing thread id
-a
system-wide collection from all CPUs
-C
-C 0-3,5
count only on list of CPUs
Controlling output
perf also has options to control the output.
Option
Example
Description
-B
Big Number
-x
-x,
programmable friendly output
--table
Display time for each run (-r) in a table format
Last updated
Was this helpful?