Basic counters with e.g., 10 repetitions:
$ perf stat -r 10 command
Commands below assume
$ pid=`pgrep someprocessofinterest`
$ tts=120 # time to sample
where the execution of someprocessofinterest
is appropriately stopped / resumed
using the getchar hackish
technique.
$ perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores,L2-loads,L2-load-misses,L2-stores,LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches -p $pid sleep ${tts}
For a given process, e.g., BFS app:
$ pid=`pgrep BFS`; perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores,L2-loads,L2-load-misses,L2-stores,LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches -p $pid sleep 4
$ perf record -F 99 -p ${pid} -g -o perf.data --sleep ${tts}
Requires downloading Brendan Gregg's FlameGraph scripts. Assuming below is run from directory containing the scripts:
$ data=path/to/perf.data
$ fn=somefunctionofinterest
$ out=/tmp/stack.svg
$ perf script -i ${data} | ./stackcollapse-perf.pl | grep ${fn} | ./flamegraph.pl > ${out}