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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With