Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read performance counters periodically in linux

Tags:

linux

perf

Is there a way to read performance counters periodically in linux?

Something like perf stat with the ability to sample every X cycles is what I'm looking for.

Basically I would like to be able to read the instruction counter (number of instructions executed) every X amount of cpu cycles for some program.

like image 881
Ben J Avatar asked Aug 26 '12 17:08

Ben J


1 Answers

Good news: In the next kernel (Linux 3.9), perf stat will have an option -I msecs to print event deltas at regular time intervals.

https://patchwork.kernel.org/patch/2004891/

$ perf stat -I 1000 -e cycles noploop 10
noploop for 10 seconds
1.000086918         2385155642 cycles                    #    0.000 GHz
2.000267937         2392279774 cycles                    #    0.000 GHz
3.000385400         2390971450 cycles                    #    0.000 GHz
4.000504408         2390996752 cycles                    #    0.000 GHz
5.000626878         2390853097 cycles                    #    0.000 GHz

http://man7.org/linux/man-pages/man1/perf-stat.1.html

-I msecs, --interval-print msecs

Print count deltas every N milliseconds (minimum: 10ms)

like image 190
fireboot Avatar answered Sep 21 '22 02:09

fireboot