OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Produce metrics analyzing the output of a stress test | 7 # Produce metrics analyzing the output of a stress test |
8 | 8 |
| 9 source "$(dirname ${0})/stress_test_common" |
| 10 |
9 set -e | 11 set -e |
10 | 12 |
11 error() { | |
12 echo "error: ${@}" >&2 | |
13 } | |
14 | |
15 # Given a token, search for and count the instances of lines from the | |
16 # logfile that start with the token. | |
17 count_result() { | |
18 if [ ! -z "${1}" ]; then | |
19 echo $(cat "${log}" | grep "^${1} " | wc -l) | |
20 else | |
21 echo 0 | |
22 fi | |
23 } | |
24 | |
25 # Given a token, search for and compute the percentiles from logfile. | 13 # Given a token, search for and compute the percentiles from logfile. |
26 compute_percentiles() { | 14 compute_percentiles() { |
27 if [ ! -z "${1}" ]; then | 15 if [ ! -z "${1}" ]; then |
28 local pctls=".5 .9 1" | 16 local pctls=".5 .9 1" |
29 local lines=$(count_result ${1}) | 17 local lines=$(count_result ${1}) |
30 for p in $pctls; do | 18 for p in $pctls; do |
31 local count="$(echo "${lines} * $p" | bc -lq | cut -d. -f1)" | 19 local count="$(echo "${lines} * $p" | bc -lq | cut -d. -f1)" |
32 echo -n $(cat ${log} \ | 20 echo -n $(cat ${log} \ |
33 | grep ${1} \ | 21 | grep ${1} \ |
34 | cut -d' ' -f2 \ | 22 | cut -d' ' -f2 \ |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | awk '{printf "%.2f\n", $0}')" | 115 | awk '{printf "%.2f\n", $0}')" |
128 echo "${pct_savings}% savings (xz)" | 116 echo "${pct_savings}% savings (xz)" |
129 | 117 |
130 echo "$(compute_percentiles "TIME_GEN")to generate a patch (50th 90th 100th)" | 118 echo "$(compute_percentiles "TIME_GEN")to generate a patch (50th 90th 100th)" |
131 echo "$(compute_percentiles "TIME_APPLY")to apply a patch (50th 90th 100th)" | 119 echo "$(compute_percentiles "TIME_APPLY")to apply a patch (50th 90th 100th)" |
132 echo "$(compute_percentiles "TIME_BSDIFF")for bsdiff (50th 90th 100th)" | 120 echo "$(compute_percentiles "TIME_BSDIFF")for bsdiff (50th 90th 100th)" |
133 echo "$(compute_percentiles "TIME_BSPATCH")for bspatch (50th 90th 100th)" | 121 echo "$(compute_percentiles "TIME_BSPATCH")for bspatch (50th 90th 100th)" |
134 } | 122 } |
135 | 123 |
136 main "${@}" | 124 main "${@}" |
OLD | NEW |