The targets of profiling
An example of profiling application demonstrates how to profile a program. Besides it, perf
can also profile targets based on other qualifications:
Target | Option |
---|---|
Program | “perf record program”. |
Process | “perf record -p pid”. Pid is process ID. |
Thread | “perf record -t tid”. Tid is thread ID. |
User | “perf record -t uid”. Uid can be user ID or name. |
CPU | “perf record -C cpuid”. Cpuid the CPU ID. |
System-wide | “perf record -a”. Profile all CPUs in the system. This is the default behaviour. |
More words about -a
option: Since it is the default behavior when no target is designated, “perf record -a
“ is synonym to “perf record
“. A common example is to profile the system in 10
seconds:
# perf record -F 99 -a sleep 10
-F
option denotes the sampling frequency. Use an odd number, such as 99
, is to avoid lockstep sampling (Please refer perf CPU Sampling and What is lockstep sampling?).