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
9 source "$(dirname ${0})/stress_test_common"
13 # Given a token, search for and compute the percentiles from logfile.
14 compute_percentiles
() {
15 if [ ! -z "${1}" ]; then
17 local lines
=$
(count_result
${1})
19 local count
="$(echo "${lines} * $p" | bc -lq | cut -d. -f1)"
20 echo -n $
(cat ${log} \
35 USAGE: $(basename ${0}) logfile
37 Analyze the logfile of a stress test and produce metrics.
44 if [ ! -f "${log}" ]; then
45 error
"\"${log}\" not found"
50 $(count_result "PASS_COURGETTE") successful courgette patches
51 $(count_result "FAIL_COURGETTE") failed courgette patches
52 $(count_result "FAIL_DISASSEMBLE") failed to disassemble/assemble
53 $(count_result "PASS_BSDIFF") succesful bsdiff patches
54 $(count_result "FAIL_BSDIFF") failed bsdiff patches
55 $(count_result "BEST_COURGETTE") patch(es) where courgette is smaller (bz2)
56 $(count_result "BEST_BSDIFF") patch(es) where bsdiff is smaller (bz2)
57 $(count_result "BEST_TIE") patch(es) where both are the same size (bz2)
58 $(count_result "XZBEST_COURGETTE") patch(es) where courgette (xz) is smaller
59 $(count_result "XZBEST_BSDIFF") patch(es) where bsdiff is smaller (xz)
60 $(count_result "XZBEST_TIE") patch(es) where both are the same size (xz)
63 # Log file has the format "^SIZE courgette=... bsdiff=..."
64 local courgette_total
="$(cat "${log}" \
67 | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')"
68 echo "${courgette_total} bytes for a courgette payload (bz2)"
70 local courgette_total_xz
="$(cat "${log}" \
73 | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')"
74 echo "${courgette_total_xz} bytes for a courgette payload (xz)"
76 local bsdiff_total
="$(cat "${log}" \
79 | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')"
80 echo "${bsdiff_total} bytes for a bsdiff payload"
82 local best_total
="$(cat "${log}" \
84 | awk 'BEGIN{sum=0} {sum += $2} END{print sum}')"
85 echo "${best_total} bytes for a best-choice payload (bz2)"
87 local best_total_xz
="$(cat "${log}" \
89 | awk 'BEGIN{sum=0} {sum += $2} END{print sum}')"
90 echo "${best_total_xz} bytes for a best-choice payload (xz)"
92 local pct
="$(echo "100*${best_total}/${bsdiff_total}" \
94 | awk '{printf "%.2f
\n", $0}')"
95 echo "${pct}% of a bsdiff-only payload (bz2)"
97 local pct
="$(echo "100*${best_total_xz}/${bsdiff_total}" \
99 | awk '{printf "%.2f
\n", $0}')"
100 echo "${pct}% of a bsdiff-only payload (xz)"
102 local savings
="$((bsdiff_total - best_total))"
103 echo "${savings} bytes saved by courgette (bz2)"
105 local savings_xz
="$((bsdiff_total - best_total_xz))"
106 echo "${savings} bytes saved by courgette (xz)"
108 local pct_savings
="$(echo "100*${savings}/${bsdiff_total}" \
110 | awk '{printf "%.2f
\n", $0}')"
111 echo "${pct_savings}% savings (bz2)"
113 local pct_savings
="$(echo "100*${savings_xz}/${bsdiff_total}" \
115 | awk '{printf "%.2f
\n", $0}')"
116 echo "${pct_savings}% savings (xz)"
118 echo "$(compute_percentiles "TIME_GEN
")to generate a patch (50th 90th 100th)"
119 echo "$(compute_percentiles "TIME_APPLY
")to apply a patch (50th 90th 100th)"
120 echo "$(compute_percentiles "TIME_BSDIFF
")for bsdiff (50th 90th 100th)"
121 echo "$(compute_percentiles "TIME_BSPATCH
")for bspatch (50th 90th 100th)"