forked from gormanm/mmtests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard-kernels-smart.sh
executable file
·381 lines (346 loc) · 8.76 KB
/
dashboard-kernels-smart.sh
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#!/bin/bash
export SCRIPT=`basename $0 | sed -e 's/\./\\\./'`
export SCRIPTDIR=`echo $0 | sed -e "s/$SCRIPT//"`
. $SCRIPTDIR/shellpacks/common.sh
. $SCRIPTDIR/shellpacks/common-config.sh
. $SCRIPTDIR/config
KERNEL_BASE=
KERNEL_COMPARE=
KERNEL_EXCLUDE=
while [ "$1" != "" ]; do
case $1 in
--format)
FORMAT=$2
FORMAT_CMD="--format $FORMAT"
shift 2
;;
--output-dir)
OUTPUT_DIRECTORY=$2
shift 2
;;
--baseline)
KERNEL_BASE=$2
shift 2
;;
--compare)
KERNEL_COMPARE="$2"
shift 2
;;
--webroot)
REPORTROOT="$2"
shift 2
;;
--result-dir)
cd "$2" || die Result directory does not exist or is not directory
shift 2
;;
--sort-version)
SORT_VERSION=yes
shift
;;
--top)
TOPNUM="$2"
shift 2
;;
--topout)
TOPOUT="$2"
shift 2
;;
--toplatest)
TOPLATEST=yes
shift
;;
--table-id)
TABLEID="$2"
shift 2
;;
*)
echo Unrecognised argument: $1 1>&2
shift
;;
esac
done
FORMAT_CMD=
if [ "$FORMAT" != "" ]; then
FORMAT_CMD="--format $FORMAT"
fi
if [ "$OUTPUT_DIRECTORY" != "" -a ! -e "$OUTPUT_DIRECTORY" ]; then
mkdir -p $OUTPUT_DIRECTORY
fi
if [ "$OUTPUT_DIRECTORY" != "" -a ! -d "$OUTPUT_DIRECTORY" ]; then
echo Output directory is not a directory
exit -1
fi
if [ `ls "$FIRST_ITERATION_PREFIX"tests-timestamp-* 2> /dev/null | wc -l` -eq 0 ]; then
die This does not look like a mmtests results directory
fi
if [ -n "$KERNEL_BASE" ]; then
for KERNEL in $KERNEL_COMPARE $KERNEL_BASE; do
if [ ! -e "$FIRST_ITERATION_PREFIX"tests-timestamp-$KERNEL ]; then
die "Cannot find results for kernel '$KERNEL'."
fi
done
else
if [ -n "$KERNEL_COMPARE" ]; then
die "Specifying --compare without --baseline is invalid!"
fi
fi
# Build a list of kernels
if [ "$KERNEL_BASE" != "" ]; then
KERNEL_LIST=$KERNEL_BASE
for KERNEL in $KERNEL_COMPARE; do
KERNEL_LIST=$KERNEL_LIST,$KERNEL
done
else
[ -n "$ITERATIONS" ] && pushd $FIRST_ITERATION_PREFIX > /dev/null
for KERNEL in `grep -H ^start tests-timestamp-* | awk -F : '{print $4" "$1}' | sort -n | awk '{print $2}' | sed -e 's/tests-timestamp-//'`; do
EXCLUDE=no
for TEST_KERNEL in $KERNEL_EXCLUDE; do
if [ "$TEST_KERNEL" = "$KERNEL" ]; then
EXCLUDE=yes
fi
done
if [ "$EXCLUDE" = "no" ]; then
if [ "$KERNEL_BASE" = "" ]; then
KERNEL_BASE=$KERNEL
KERNEL_LIST=$KERNEL
else
KERNEL_LIST="$KERNEL_LIST,$KERNEL"
fi
fi
done
[ -n "$ITERATIONS" ] && popd > /dev/null
fi
if [ "$SORT_VERSION" = "yes" ]; then
LIST_SORT=$KERNEL_LIST
KERNEL_LIST=
KERNEL_BASE=
LIST_SORTED=`echo $LIST_SORT | sed -e 's/,/\n/g' | sort -t . -k1 -k2 -k3 -n`
LIST_SORTED_STRIPPED=
# Strip so only the latest stable major versions are included
declare -a LIST_ARRAY
read -r -a LIST_ARRAY <<< $LIST_SORTED
NR_ELEMENTS=${#LIST_ARRAY[@]}
for INDEX in ${!LIST_ARRAY[@]}; do
KERNEL=${LIST_ARRAY[$INDEX]}
CURRENT_MAJOR=`echo $KERNEL | awk -F . '{print $1"."$2}'`
if [ $((INDEX+1)) -eq $NR_ELEMENTS ]; then
LIST_SORTED_STRIPPED+=$KERNEL
else
NEXT_MAJOR=`echo ${LIST_ARRAY[$((INDEX+1))]} | awk -F . '{print $1"."$2}'`
if [ "$NEXT_MAJOR" != "$CURRENT_MAJOR" ]; then
LIST_SORTED_STRIPPED+="$KERNEL "
fi
fi
done
for KERNEL in $LIST_SORTED_STRIPPED; do
if [ "$KERNEL_BASE" = "" ]; then
KERNEL_BASE=$KERNEL
KERNEL_LIST=$KERNEL
else
KERNEL_LIST="$KERNEL_LIST,$KERNEL"
fi
done
fi
KERNEL_LIST_ITER=`echo $KERNEL_LIST | sed -e 's/,/ /g'`
declare -a GOOD_STRINGS
declare -a GOOD_COLOURS
declare -a BAD_STRINGS
declare -a BAD_COLOURS
GOOD_STRINGS[0]="Satisfactory"
GOOD_STRINGS[1]="Good"
GOOD_STRINGS[2]="Great"
GOOD_STRINGS[3]="Excellent"
BAD_STRINGS[0]="Unsatisfactory"
BAD_STRINGS[1]="Bad"
BAD_STRINGS[2]="Awful"
BAD_STRINGS[3]="Abominable"
GOOD_COLOURS[3]="#007800"
GOOD_COLOURS[2]="#009F00"
GOOD_COLOURS[1]="#00C700"
GOOD_COLOURS[0]="#00EE00"
BAD_COLOURS[3]="#780000"
BAD_COLOURS[2]="#9F0000"
BAD_COLOURS[1]="#C70000"
BAD_COLOURS[0]="#EE0000"
UNKNOWN_COLOUR="#FFFFFF"
NEUTRAL_COLOUR="#A0A0A0"
if [ "$FORMAT" = "html" ]; then
echo "<table id=\"$TABLEID\" cellspacing=0>"
fi
function tablecell() {
# Call: GRATIO DESCRIPTION COLOUR
GRATIO=$1
DESCRIPTION=$2
COLOUR=$3
SUBREPORT=$4
if [ "$FORMAT" != "html" ]; then
printf "%8.4f %-15s " $GRATIO $DESCRIPTION
else
if [ "$REPORTROOT" != "" ]; then
echo "<td bgcolor=\"$COLOUR\"><font size=1><a href=\"$REPORTROOT#$SUBREPORT\" title=\""
cat $COMPARE_FILE
echo "\">$GRATIO</a></font></td>"
else
echo "<td bgcolor=\"$COLOUR\" title=\""
cat $COMPARE_FILE
echo "\"><font size=1>$GRATIO</font></td>"
fi
fi
}
AOPEN=
ACLOSE=
if [ "$REPORTROOT" != "" ]; then
AOPEN="<a href=\"$REPORTROOT\" title="$KERNEL_LIST">"
ACLOSE="</a>"
fi
KERNEL_LIST_SPACE=`echo $KERNEL_LIST | sed -e 's/,/ /g'`
read -a KERNEL_NAMES <<< $KERNEL_LIST_SPACE
for SUBREPORT in `grep "test begin :: " "$FIRST_ITERATION_PREFIX"tests-timestamp-$KERNEL_BASE | awk '{print $4}'`; do
COMPARE_CMD="compare-mmtests.pl --print-ratio -d . -b $SUBREPORT -n $KERNEL_LIST"
case $SUBREPORT in
*)
COMPARE_FILE=`mktemp`
$COMPARE_CMD > $COMPARE_FILE
GMEAN=`grep ^Gmean $COMPARE_FILE`
DMEAN=`grep ^Dmean $COMPARE_FILE`
GOODNESS=Unknown
COLOUR=$UNKNOWN_COLOUR
RATIO=0
DESCRIPTION=Unknown
if [ "$FORMAT" != "html" ]; then
printf "%-20s %-8s" $SUBREPORT $GOODNESS
else
echo "<tr>"
echo "<td bgcolor=\"$COLOUR\"><font size=1>$SUBREPORT</font></td>"
fi
if [ -n "$DMEAN" ]; then
GOODNESS=`echo $GMEAN | awk '{print $2}'`
NR_FIELDS=`echo $GMEAN | awk '{print NF}'`
if [ $NR_FIELDS -gt 3 ]; then
FIELD_LIST=`seq 4 $NR_FIELDS`
else
FIELD_LIST=3
fi
NAME_INDEX=-1
for FIELD in $FIELD_LIST; do
NAME_INDEX=$((NAME_INDEX+1))
GRATIO=`echo $GMEAN | awk "{print \\$$FIELD}"`
DDIFF=`echo $DMEAN | awk "{print \\$$FIELD}"`
if [ "$DDIFF" != "nan" ]; then
DIFF_ADJUSTED=`perl -e "print (($DDIFF*10000))"`
DELTA=$((DIFF_ADJUSTED))
if [ "$TOPOUT" != "" ]; then
if [ "$TOPLATEST" != "yes" -o $FIELD -eq $NR_FIELDS ]; then
echo "$DDIFF $GRATIO $SUBREPORT $TABLEID ${KERNEL_NAMES[$NAME_INDEX]}" >> $TOPOUT
fi
fi
if [ $DIFF_ADJUSTED -lt 0 ]; then
DELTA=$((-DIFF_ADJUSTED))
fi
if [ $DELTA -lt 10000 ]; then
DESCRIPTION="Neutral"
COLOUR=$NEUTRAL_COLOUR
else
INDEX=
if [ $DELTA -lt 20000 ]; then
INDEX=0
elif [ $DELTA -le 30000 ]; then
INDEX=1
elif [ $DELTA -le 40000 ]; then
INDEX=2
else
INDEX=3
fi
if [ "$GOODNESS" = "Higher" ]; then
if [ $DIFF_ADJUSTED -gt 0 ]; then
DESCRIPTION=${GOOD_STRINGS[$INDEX]}
COLOUR=${GOOD_COLOURS[$INDEX]}
else
DESCRIPTION=${BAD_STRINGS[$INDEX]}
COLOUR=${BAD_COLOURS[$INDEX]}
fi
else
if [ $DIFF_ADJUSTED -lt 0 ]; then
DESCRIPTION=${GOOD_STRINGS[$INDEX]}
COLOUR=${GOOD_COLOURS[$INDEX]}
else
DESCRIPTION=${BAD_STRINGS[$INDEX]}
COLOUR=${BAD_COLOURS[$INDEX]}
fi
fi
fi
fi
tablecell $GRATIO $DESCRIPTION $COLOUR $SUBREPORT
done
elif [ -n "$GMEAN" ]; then
GOODNESS=`echo $GMEAN | awk '{print $2}'`
NR_FIELDS=`echo $GMEAN | awk '{print NF}'`
if [ $NR_FIELDS -gt 3 ]; then
FIELD_LIST=`seq 4 $NR_FIELDS`
else
FIELD_LIST=3
fi
for FIELD in $FIELD_LIST; do
RATIO=`echo $GMEAN | awk "{print \\$$FIELD}"`
if [ "$RATIO" != "nan" ]; then
RATIO_ADJUSTED=`perl -e "print (($RATIO*10000))"`
DMEAN=`perl -e "printf \"%4.2f\", (abs (1-$RATIO))"`
DELTA=$((RATIO_ADJUSTED-10000))
if [ $DELTA -lt 0 ]; then
DELTA=$((-DELTA))
fi
if [ "$TOPOUT" != "" ]; then
if [ "$TOPLATEST" != "yes" -o $FIELD -eq $NR_FIELDS ]; then
echo "$DMEAN $RATIO $SUBREPORT $TABLEID ${KERNEL_NAMES[$NAME_INDEX]}" >> $TOPOUT
fi
fi
if [ $DELTA -lt 100 ]; then
DESCRIPTION="Neutral"
COLOUR=$NEUTRAL_COLOUR
else
INDEX=
if [ $DELTA -lt 200 ]; then
INDEX=0
elif [ $DELTA -le 500 ]; then
INDEX=1
elif [ $DELTA -le 1000 ]; then
INDEX=2
else
INDEX=3
fi
if [ "$GOODNESS" = "Higher" ]; then
if [ $RATIO_ADJUSTED -gt 10000 ]; then
DESCRIPTION=${GOOD_STRINGS[$INDEX]}
COLOUR=${GOOD_COLOURS[$INDEX]}
else
DESCRIPTION=${BAD_STRINGS[$INDEX]}
COLOUR=${BAD_COLOURS[$INDEX]}
fi
else
if [ $RATIO_ADJUSTED -lt 10000 ]; then
DESCRIPTION=${GOOD_STRINGS[$INDEX]}
COLOUR=${GOOD_COLOURS[$INDEX]}
else
DESCRIPTION=${BAD_STRINGS[$INDEX]}
COLOUR=${BAD_COLOURS[$INDEX]}
fi
fi
fi
fi
tablecell $RATIO $DESCRIPTION $COLOUR $SUBREPORT
done
else
tablecell 0 Unknown $UNKNOWN_COLOUR $SUBREPORT
fi
if [ "$FORMAT" != "html" ]; then
echo
else
echo "</tr>"
fi
rm $COMPARE_FILE
esac
done
if [ "$FORMAT" = "html" ]; then
echo "</table>"
fi