forked from embecosm/rise-rvv-tcg-qemu-tooling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collate-qemu-times.awk
184 lines (171 loc) · 4.01 KB
/
collate-qemu-times.awk
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Awk script to collate QEMU run times
# Copyright (C) 2023 Embecosm Limited
# Contributor Jeremy Bennett <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
# Invoke as awk -f collate-times.awk < <input file>
# Dump help message and exit
# \param[in] rc Return code on exit
function dohelp(rc) {
printf "Usage: awk -f collate-qemu-times.awk --txt|--csv|--md --quiet|--verbose < <log file>\n"
return rc
}
# Print out table header in standad format
function phdr(title, pformat) {
printf "\n%s\n", title
for (i = 0; i < length(title); i++)
printf "="
printf "\n\n"
switch (pformat) {
case "--csv":
printf "\"Benchmark\",\"Real\",\"User\",\"Sys\"\n"
break
case "--md":
printf "| %-25s | %12s | %12s | %12s |\n", "Benchmark", \
"Real", "User", "Sys"
printf "| %-25s | %12s | %12s | %12s |\n", \
":------------------------", "-----------:", "-----------:", \
"-----------:"
break
case "--txt":
printf "%-25s %12s %12s %12s\n", "Benchmark", "Real", "User", "Sys"
printf "%-25s %12s %12s %12s\n", "---------", "----", "----", "---"
break
default:
break;
}
}
BEGIN {
# Get the baseline data
if (ARGC != 3)
dohelp(1)
else {
switch (ARGV[1]) {
case "--txt":
case "--csv":
case "--md":
pformat = ARGV[1]
break
default:
dohelp(1)
}
switch (ARGV[2]) {
case "--verbose":
case "--quiet":
verbosity = ARGV[2]
break
default:
dohelp(1)
}
ARGC = 1
}
# Flag to show when we should be capturing data
capture = 0
}
# Start capturing results
/^Appending benchmark run logs/ {
capture = 1
}
# Stop capturing results
/^Checking results/ {
capture = 0
}
# Get name for new set of data
capture && /^Run log for/ {
bmrun = $4
split (bmrun, t, "-")
if ( bm != t[1]) {
bm = t[1]
bmtotreal[bm] = 0
bmtotuser[bm] = 0
bmtotsys[bm] = 0
bmmaxreal[bm] = 0
bmmaxuser[bm] = 0
bmmaxsys[bm] = 0
}
}
# Capture real times
capture && /^(real|sys|user)/ {
patsplit ($2, t, "([[:digit:]]+)|m|.|s")
tot = t[1] *60 + t[3] + t[5] / 1000
switch ($1) {
case "real":
bmreal[bmrun] = tot
bmtotreal[bm] += tot
if (tot > bmmaxreal[bm])
bmmaxreal[bm] = tot
break
case "user":
bmuser[bmrun] = tot
bmtotuser[bm] += tot
if (tot > bmmaxuser[bm])
bmmaxuser[bm] = tot
break
case "sys":
bmsys[bmrun] = tot
bmtotsys[bm] += tot
if (tot > bmmaxsys[bm])
bmmaxsys[bm] = tot
break
}
}
END {
phdr("Total timings per benchmark", pformat)
PROCINFO["sorted_in"] = "@ind_str_asc"
for (bm in bmtotreal) {
switch (pformat) {
case "--csv":
printf "\"%s\",\"%.3f\",\"%.3f\",\"%.3f\"\n", bm, \
bmtotreal[bm], bmtotuser[bm], bmtotsys[bm]
break
case "--md":
printf "| %-25s | %12.3f | %12.3f | %12.3f |\n", bm, \
bmtotreal[bm], bmtotuser[bm], bmtotsys[bm]
break
case "--txt":
printf "%-25s %12.3f %12.3f %12.3f\n", bm, bmtotreal[bm], \
bmtotuser[bm], bmtotsys[bm]
break
default:
}
}
if (verbosity == "--verbose") {
phdr("Timings per run", pformat)
PROCINFO["sorted_in"] = "@ind_str_asc"
for (bm in bmreal) {
switch (pformat) {
case "--csv":
printf "\"%s\",\"%.3f\",\"%.3f\",\"%.3f\"\n", bm, \
bmreal[bm], bmuser[bm], bmsys[bm]
break
case "--md":
printf "| %-25s | %12.3f | %12.3f | %12.3f |\n", bm, bmreal[bm], \
bmuser[bm], bmsys[bm]
break
case "--txt":
printf "%-25s %12.3f %12.3f %12.3f\n", bm, bmreal[bm], \
bmuser[bm], bmsys[bm]
break
default:
}
}
phdr("Longest run by benchmark", pformat)
PROCINFO["sorted_in"] = "@ind_str_asc"
for (bm in bmmaxreal) {
switch (pformat) {
case "--csv":
printf "\"%s\",\"%.3f\",\"%.3f\",\"%.3f\"\n", bm, \
bmmaxreal[bm], bmmaxuser[bm], bmmaxsys[bm]
break
case "--md":
printf "| %-25s | %12.3f | %12.3f | %12.3f |\n", bm, \
bmmaxreal[bm], bmmaxuser[bm], bmmaxsys[bm]
break
case "--txt":
printf "%-25s %12.3f %12.3f %12.3f\n", bm, bmmaxreal[bm], \
bmmaxuser[bm], bmmaxsys[bm]
break
default:
}
}
}
}