3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Produce metrics analyzing the output of a stress test
12 echo "error: ${@}" >&2
15 # Given a token, search for and count the instances of lines from the
16 # logfile that start with the token.
18 if [ ! -z "${1}" ]; then
19 echo $
(cat "${log}" |
grep "^${1} " |
wc -l)
29 USAGE: $(basename ${0}) logfile
31 Analyze the logfile of a stress test and produce metrics.
38 if [ ! -f "${log}" ]; then
39 error
"\"${log}\" not found"
44 $(count_result "PASS_COURGETTE") successful courgette patches
45 $(count_result "FAIL_COURGETTE") failed courgette patches
46 $(count_result "FAIL_DISASSEMBLE") failed to disassemble/assemble
47 $(count_result "PASS_BSDIFF") succesful bsdiff patches
48 $(count_result "FAIL_BSDIFF") failed bsdiff patches
49 $(count_result "BEST_COURGETTE") patch(es) where courgette is smaller
50 $(count_result "BEST_BSDIFF") patch(es) where bsdiff is smaller
51 $(count_result "BEST_TIE") patch(es) where both are the same size
54 # Log file has the format "^SIZE courgette=... bsdiff=..."
55 local courgette_total
="$(cat "${log}" \
58 | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')"
59 echo "${courgette_total} bytes for a courgette payload"
61 local bsdiff_total
="$(cat "${log}" \
64 | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')"
65 echo "${bsdiff_total} bytes for a bsdiff payload"
67 local best_total
="$(cat "${log}" \
69 | awk 'BEGIN{sum=0} {sum += $2} END{print sum}')"
70 echo "${best_total} bytes for a best-choice payload"
72 local pct
="$(echo "100*${best_total}/${bsdiff_total}" \
74 | awk '{printf "%.2f
\n", $0}')"
75 echo "${pct}% of a bsdiff-only payload"
77 local savings
="$((bsdiff_total - best_total))"
78 echo "${savings} bytes saved by courgette"
80 local pct_savings
="$(echo "100*${savings}/${bsdiff_total}" \
82 | awk '{printf "%.2f
\n", $0}')"
83 echo "${pct_savings}% savings"