Skip to content

Instantly share code, notes, and snippets.

@nyrahul
Created March 9, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyrahul/2275dcb6dd2d8e81b0b0420a6b46fc6a to your computer and use it in GitHub Desktop.
Save nyrahul/2275dcb6dd2d8e81b0b0420a6b46fc6a to your computer and use it in GitHub Desktop.
Get Perf statistics over multiple run and show it in column format
#!/bin/bash
OUTFILE=perf_out.txt
rm perf*.txt
for((i=0;i<4;i++)); do
#timeout -s SIGINT 12 perf stat -e dTLB-loads -e cs,cycles,instructions -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e dTLB-stores -e cs,cycles,instructions -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e dTLB-load-misses,dTLB-store-misses -e cs,cycles,instructions -D 2000 -a -o perf$i.txt
timeout -s SIGINT 12 perf stat -e cs,cycles,instructions -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e cs,cycles,instructions -e cache-misses,cache-references -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e cs,cycles,instructions -e branches,branch-misses -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e cs,cycles,instructions -e bus-cycles,ref-cycles -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e cycles -e cpu/event=0x08,umask=0x10,name=dcycles/ -e cpu/event=0x85,umask=0x10,name=icycles/ -D 2000 -a -o perf$i.txt
#timeout -s SIGINT 12 perf stat -e cache-misses -e cpu/event=0xbc,umask=0x18,name=dreads/ -e cpu/event=0xbc,umask=0x28,name=ireads/ -D 2000 -a -o perf$i.txt
cat perf$i.txt
[[ $i -eq 0 ]] && tail -n +6 perf$i.txt | head -n -3 | tr -s ' ' | cut -d ' ' -f 3 | paste -s -d ' ' > $OUTFILE
tail -n +6 perf$i.txt | head -n -3 | tr -s ' ' | cut -d ' ' -f 2 | paste -s -d ' ' >> $OUTFILE
sleep 1
done
column -s ' ' -t $OUTFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment