-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperf_flame.sh
More file actions
executable file
·27 lines (22 loc) · 877 Bytes
/
perf_flame.sh
File metadata and controls
executable file
·27 lines (22 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# READ AND THANKS TO https://www.brendangregg.com/blog/2014-10-31/cpi-flame-graphs.html
CMD="$@"
FLAME="flame/FlameGraph/"
#EVENT1="pm_1plus_ppc_cmpl:k"
#EVENT2="cycles:k" # an event1 implys and event2 but not vise versa
EVENT1="instructions:k"
EVENT2="cycles:k"
PERF="perf record -a -e $EVENT1,$EVENT2 -g"
echo "RUNING $PERF $CMD"
$PERF $CMD
# make perf.data human readable
perf script > perf_script.data
echo "running flame scripts"
# now we need to seperate into 2 different files
$FLAME/stackcollapse-perf.pl --event-filter=$EVENT1 perf_script.data > folded_ev1
$FLAME/stackcollapse-perf.pl --event-filter=$EVENT2 perf_script.data > folded_ev2
# stack collapse behaves differently when given 2 files!
$FLAME/difffolded.pl folded_ev1 folded_ev2 > out.perf-folded
# finally we can make the graph
$FLAME/flamegraph.pl out.perf-folded > perf.svg
echo "done"