diff options
author | paulgazz@chromium.org <paulgazz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 13:09:02 +0000 |
---|---|---|
committer | paulgazz@chromium.org <paulgazz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 13:09:02 +0000 |
commit | 888667dad66d12239d1fde896721114ea2406802 (patch) | |
tree | 3deb5661b626324db8f7f9341cf488261741dafe /courgette | |
parent | c48fece0c35a6bfdf73ee9ba6e6f18263d0748d8 (diff) | |
download | chromium_src-888667dad66d12239d1fde896721114ea2406802.zip chromium_src-888667dad66d12239d1fde896721114ea2406802.tar.gz chromium_src-888667dad66d12239d1fde896721114ea2406802.tar.bz2 |
Created a script to measure the size of payloads made by courgette, bsdiff, and both.
Also, the stress tester is updated to remove compressing the bsdiff patch, since the command-line bsdiff tool already compresses the patch.
BUG=244607
Review URL: https://chromiumcodereview.appspot.com/15904022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette')
-rwxr-xr-x | courgette/analyze_stress_test | 85 | ||||
-rwxr-xr-x | courgette/run_stress_test | 43 |
2 files changed, 98 insertions, 30 deletions
diff --git a/courgette/analyze_stress_test b/courgette/analyze_stress_test new file mode 100755 index 0000000..f6d0e80 --- /dev/null +++ b/courgette/analyze_stress_test @@ -0,0 +1,85 @@ +#!/bin/bash + +# Copyright 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Produce metrics analyzing the output of a stress test + +set -e + +error() { + echo "error: ${@}" >&2 +} + +# Given a token, search for and count the instances of lines from the +# logfile that start with the token. +count_result() { + if [ ! -z "${1}" ]; then + echo $(cat "${log}" | grep "^${1} " | wc -l) + else + echo 0 + fi +} + +main() { + if [ $# -lt 1 ]; then + cat <<EOF + +USAGE: $(basename ${0}) logfile + +Analyze the logfile of a stress test and produce metrics. + +EOF + exit 1 + fi + + local log="${1}" + if [ ! -f "${log}" ]; then + error "\"${log}\" not found" + exit 1 + fi + + cat <<EOF +$(count_result "PASS_COURGETTE") successful courgette patches +$(count_result "FAIL_COURGETTE") failed courgette patches +$(count_result "PASS_BSDIFF") succesful bsdiff patches +$(count_result "FAIL_BSDIFF") failed bsdiff patches +$(count_result "BEST_COURGETTE") patch(es) where courgette is smaller +$(count_result "BEST_BSDIFF") patch(es) where bsdiff is smaller +$(count_result "BEST_TIE") patch(es) where both are the same size +EOF + + # Log file has the format "^SIZE courgette=... bsdiff=..." + local courgette_total="$(cat "${log}" \ + | grep "^SIZE " \ + | cut -d' ' -f2 \ + | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')" + echo "${courgette_total} bytes for a courgette payload" + + local bsdiff_total="$(cat "${log}" \ + | grep "^SIZE " \ + | cut -d' ' -f3 \ + | awk -F= 'BEGIN{sum=0} {sum += $2} END{print sum}')" + echo "${bsdiff_total} bytes for a bsdiff payload" + + local best_total="$(cat "${log}" \ + | grep "^BEST_" \ + | awk 'BEGIN{sum=0} {sum += $2} END{print sum}')" + echo "${best_total} bytes for a best-choice payload" + + local pct="$(echo "100*${best_total}/${bsdiff_total}" \ + | bc -lq \ + | awk '{printf "%.2f\n", $0}')" + echo "${pct}% of a bsdiff-only payload" + + local savings="$((bsdiff_total - best_total))" + echo "${savings} bytes saved by courgette" + + local pct_savings="$(echo "100*${savings}/${bsdiff_total}" \ + | bc -lq \ + | awk '{printf "%.2f\n", $0}')" + echo "${pct_savings}% savings" +} + +main "${@}" diff --git a/courgette/run_stress_test b/courgette/run_stress_test index 9daa5a9..cb0687d 100755 --- a/courgette/run_stress_test +++ b/courgette/run_stress_test @@ -70,9 +70,9 @@ run_test() { courgette -apply "${file1}" "${patch}" "${apply}" cmp -s "${file2}" "${apply}" if [ "${?}" -ne 0 ]; then - echo "FAIL ${file1}" + echo "FAIL_COURGETTE ${file1}" else - echo "PASS ${file1}" + echo "PASS_COURGETTE ${file1}" local bsdiff_patch="${patches_dir}/${file1}.bsdiff_patch" local bsdiff_apply="${applied_dir}/${file2}.bsdiff_applied" bsdiff "${file1}" "${file2}" "${bsdiff_patch}" @@ -82,28 +82,16 @@ run_test() { echo "FAIL_BSDIFF ${file1}" else echo "PASS_BSDIFF ${file1}" - local patch_size="$(du -b "${patch}" | cut -f1)" + bzip2 -k -9 "${patch}" + local patch_size="$(du -b "${patch}.bz2" | cut -f1)" local bsdiff_patch_size="$(du -b "${bsdiff_patch}" | cut -f1)" echo "SIZE courgette=${patch_size} bsdiff=${bsdiff_patch_size} ${file1}" if [ "${patch_size}" -eq "${bsdiff_patch_size}" ]; then - echo "TIE ${file1}" + echo "BEST_TIE ${patch_size} ${file1}" elif [ "${patch_size}" -lt "${bsdiff_patch_size}" ]; then - echo "COURGETTE ${file1}" + echo "BEST_COURGETTE ${patch_size} ${file1}" elif [ "${patch_size}" -gt "${bsdiff_patch_size}" ]; then - echo "BSDIFF ${file1}" - fi - bzip2 -k -9 "${patch}" - bzip2 -k -9 "${bsdiff_patch}" - local patch_size_bz2="$(du -b "${patch}.bz2" | cut -f1)" - local bsdiff_patch_size_bz2="$(du -b "${bsdiff_patch}.bz2" | cut -f1)" - echo "SIZE_BZ2 courgette=${patch_size_bz2}" \ - "bsdiff=${bsdiff_patch_size_bz2} ${file1}" - if [ "${patch_size_bz2}" -eq "${bsdiff_patch_size_bz2}" ]; then - echo "TIE_BZ2 ${file1}" - elif [ "${patch_size_bz2}" -lt "${bsdiff_patch_size_bz2}" ]; then - echo "COURGETTE_BZ2 ${file1}" - elif [ "${patch_size_bz2}" -gt "${bsdiff_patch_size_bz2}" ]; then - echo "BSDIFF_BZ2 ${file1}" + echo "BEST_BSDIFF ${bsdiff_patch_size} ${file1}" fi fi fi @@ -133,17 +121,12 @@ count_result() { } cat <<EOF | tee -a "${log}" -$(count_result "PASS") successful courgette patches -$(count_result "FAIL") failed courgette patches (search log for "^FAIL ") +$(count_result "PASS_COURGETTE") successful courgette patches +$(count_result "FAIL_COURGETTE") failed courgette patches (search log for \ +"^FAIL_COURGETTE") $(count_result "PASS_BSDIFF") succesful bsdiff patches $(count_result "FAIL_BSDIFF") failed bsdiff patches -$(count_result "COURGETTE") patch(es) where courgette is smaller -$(count_result "BSDIFF") patch(es) where bsdiff is smaller -$(count_result "TIE") patch(es) where both are the same size -$(count_result "COURGETTE_BZ2") patch(es) where courgette is smaller after \ -compression -$(count_result "BSDIFF_BZ2") patch(es) where bsdiff is smaller after \ -compression -$(count_result "TIE_BZ2") patch(es) where both are the same size after \ -compression +$(count_result "BEST_COURGETTE") patch(es) where courgette is smaller +$(count_result "BEST_BSDIFF") patch(es) where bsdiff is smaller +$(count_result "BEST_TIE") patch(es) where both are the same size EOF |