run_mem_test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Copyright 2013 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Collect memory usage on the patches from run_stress_test
  6. source "$(dirname ${0})/stress_test_common"
  7. main() {
  8. if [ $# -lt 1 ]; then
  9. cat <<EOF
  10. USAGE: $(basename ${0}) dir
  11. Collect memory usage on the patches from run_stress_test
  12. EOF
  13. exit 1
  14. fi
  15. local dir="${1}"
  16. if [ ! -d "${dir}" ]; then
  17. error "\"${dir}\" not found"
  18. exit 1
  19. fi
  20. local patches_dir="${dir}/patches"
  21. find "${patches_dir}" \
  22. | grep "\.patch$" \
  23. | while read i; do
  24. local patch="${i}"
  25. local subdir_filename="${patch:$((${#patches_dir} + 1))}"
  26. local out_base="${dir}/metrics/${subdir_filename}"
  27. mkdir -p "$(dirname ${out_base})"
  28. local original="${subdir_filename%.patch}"
  29. local applied="${out_base}.applied"
  30. local apply_mem="${out_base}.apply_mem"
  31. valgrind --tool=massif --massif-out-file="${apply_mem}" courgette -apply \
  32. "${original}" "${patch}" "${applied}" &
  33. local bz2_patch="${i}.bz2"
  34. local unbz2="${out_base}.unbz2"
  35. local unbz2_mem="${out_base}.unbz2_mem"
  36. valgrind --tool=massif --massif-out-file="${unbz2_mem}" bunzip2 -c \
  37. "${bz2_patch}" > "${unbz2}" &
  38. local xz_patch="${i}.xz"
  39. local unxz="${out_base}.unxz"
  40. local unxz_mem="${out_base}.unxz_mem"
  41. valgrind --tool=massif --massif-out-file="${unxz_mem}" unxz -c \
  42. "${xz_patch}" > "${unxz}" &
  43. local bsdiff_patch="${patch%.patch}.bsdiff_patch"
  44. local applied_bsdiff="${out_base}.applied_bsdiff"
  45. local bsdiff_mem="${out_base}.bsdiff_mem"
  46. valgrind --tool=massif --massif-out-file="${bsdiff_mem}" bspatch \
  47. "${original}" "${applied_bsdiff}" "${bsdiff_patch}" &
  48. wait
  49. done
  50. }
  51. main "${@}"