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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/bin/bash
set -e
buildid_dir="global"
perf_dirs=()
event="cycles"
format="sample,overhead"
declare -A num_entries
num_entries[total]="10"
num_entries[dso]=${num_entries[total]}
num_entries[symbol]=${num_entries[total]}
add_time=false
verbose=""
OPTS="`getopt -l buildid-dir:,dir:,event:,format:,num:,num-dsos:,num-symbols:,time,verbose -o d:,e:,f:,n:,t,v -- "$@"`"
while test $# -gt 0; do
case $1 in
--buildid-dir) buildid_dir="$2"; shift ;;
--dir|-d) perf_dirs=("${perf_dirs[@]}" "$(cd $2; pwd)"); shift ;;
--event|-e) event="$2"; shift ;;
--format|-f) format="$2"; shift ;;
--num|-n) num_entries[total]="$2"; shift ;;
--num-dsos) num_entries[dso]="$2"; shift ;;
--num-symbols) num_entries[symbol]="$2"; shift ;;
--time|-t) add_time=true ;;
--verbose|-v) verbose="set -x" ;;
*) echo "ERROR: Unknown option $1"; exit 1 ;;
esac
shift
done
spectime ()
{
set -e
$verbose
local perf_dir="$1"
local data="$2"
local format="$3"
id=$(basename $perf_dir | cut -d. -f 2)
bmk=$(basename $data .data)
results_path=$(dirname $perf_dir)
time=$(cat $results_path/CINT2006.$id.ref.csv \
$results_path/CFP2006.$id.ref.csv 2>/dev/null \
| grep "^$bmk.*SelectedIteration" | cut -d, -f3)
time=$(echo "scale=0; $time/1" | bc)
echo "$bmk,time,$format" | sed -e "s/sample/$time/" -e "s/overhead/100%/"
}
$verbose
if [ "${#perf_dirs[@]}" = "0" ]; then
echo "ERROR: No --dir PERF_DIR options specified"
exit 1
fi
for perf_dir in "${perf_dirs[@]}"; do
if ! [ -d "$perf_dir" ]; then
echo "ERROR: Directory does not exist: $perf_dir"
exit 1
fi
done
echo "benchmark,symbol,$format"
for perf_dir in "${perf_dirs[@]}"; do
case "$buildid_dir" in
"global"|"none")
buildid_opt=""
;;
"local")
buildid_opt="--buildid-dir $perf_dir"
;;
*)
buildid_opt="--buildid-dir $buildid_dir"
;;
esac
for data in $(cd "$perf_dir"; ls [1-8]*.data); do
if $add_time; then
spectime "$perf_dir" "$data" "$format"
fi
for report_field in dso symbol; do
perf $buildid_opt report -i "$perf_dir/$data" --stdio \
-g none --no-children -F $report_field,$format -s sample \
-t, -w 40 2>/dev/null \
| awk "
BEGIN { found_samples=0; found_command=0 }
/^# Samples: .* of event '$event['/]/ { if (found_samples) { exit }; found_samples=1; next }
/^# .* , *Samples/ { if (found_samples) { found_command=1 }; next }
/^#/ { if (found_command) { exit } }
/^$/ { next }
{ if (found_command) { print \$0 } }
" \
| head -n ${num_entries[$report_field]}
done | head -n ${num_entries[total]} | sed -e "s/^/$(basename $data .data),/"
done
done
|