Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does perf record -P do?

I have tried the command perf record and then perf record -P, which is supposed to allow me to specify the sample period, but it does not work. The result of perf record -P is the same as the one obtained from perf record.

So what does perf record -P do in fact?

like image 375
AN00 Avatar asked Oct 22 '25 08:10

AN00


1 Answers

@Alina,

If you read the man page for perf record, you can see that perf record -P will be used to record the sample period, and not specify it.

If you want to record more/less samples and modify the period, you have to specify the command like perf record -c 2 (--count=) where 2 is the sampling period. This will mean that for every 2 occurrences of the event that you are measuring, you will have a sample for that. You can then modify the sampling period and test various values.

The other way around to express the sampling period, is to specify the average rate of samples per second (frequency) - which you can do using perf record -F. So perf record -F 1000 will record around 1000 samples per second and these samples will be generated when the hardware/PMU counter corresponding to the event overflows. This means that the kernel will dynamically adjust the sampling period.

like image 171
Arnabjyoti Kalita Avatar answered Oct 24 '25 15:10

Arnabjyoti Kalita