Update V8 to version 4.6.6.
[chromium-blink-merge.git] / courgette / analyze_mem_test
blob1e729398114dc36cd72f34bb0c855774325ff3f8
1 #!/bin/bash
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 memory metrics for run_apply_test
9 source "$(dirname ${0})/stress_test_common"
11 compute_percentiles() {
12 if [ -z "${1}" ]; then
13 return;
15 local pctls=".5 .9 1"
16 local lines=$(cat ${1} | wc -l)
17 for p in $pctls; do
18 local count="$(echo "${lines} * $p" | bc -lq | cut -d. -f1)"
19 local bytes=$(cat ${1} \
20 | cut -d' ' -f2 \
21 | sort -n \
22 | head -n$count \
23 | tail -n1)
24 echo -n "$((bytes / 1000000))MB "
25 done
28 main() {
29 if [ $# -lt 1 ]; then
30 cat <<EOF
32 USAGE: $(basename ${0}) dir
34 Produce memory metrics for run_apply_test. This shows the percentiles
35 of the max heap size across all files.
37 EOF
38 exit 1
41 local dir="${1}"
42 if [ ! -d "${dir}" ]; then
43 error "\"${dir}\" not found" exit 1
46 local metrics_dir="${dir}/metrics"
47 local metrics="${dir}/mem_per_file.txt"
49 if [ ! -f "${metrics}" ]; then
50 local metrics_tmp="${metrics}.tmp"
51 echo "computing usage percentiles for courgette. this may take a while..."
52 find "${metrics_dir}" \
53 | grep "\.apply_mem$" \
54 | while read i; do
55 local apply_mem="${i}"
56 local unbz2_mem="${apply_mem%.apply_mem}.unbz2_mem"
57 local unxz_mem="${apply_mem%.apply_mem}.unxz_mem"
58 echo -n "$apply_mem "
59 cat "${apply_mem}" "${unbz2_mem}" "${unxz_mem}" \
60 | grep "mem_heap_B" \
61 | cut -d= -f2 \
62 | sort -nr \
63 | head -n1
64 done | sort -k2 -n > "${metrics_tmp}"
65 mv "${metrics_tmp}" "${metrics}"
68 echo "$(compute_percentiles ${metrics})max heap per file for Courgette" \
69 "(50th 90th 100th)"
71 local metrics_bsdiff="${dir}/mem_per_file_bsdiff.txt"
73 if [ ! -f "${metrics_bsdiff}" ]; then
74 local metrics_bsdiff_tmp="${metrics_bsdiff}.tmp"
75 echo "computing usage percentiles for bsdiff. this may take a while..."
76 find "${metrics_dir}" \
77 | grep "\.bsdiff_mem$" \
78 | while read i; do
79 local bsdiff_mem="${i}"
80 echo -n "$bsdiff_mem "
81 cat $bsdiff_mem \
82 | grep "mem_heap_B" \
83 | cut -d= -f2 \
84 | sort -nr \
85 | head -n1
86 done | sort -k2 -n > "${metrics_bsdiff_tmp}"
87 mv "${metrics_bsdiff_tmp}" "${metrics_bsdiff}"
90 echo "$(compute_percentiles ${metrics_bsdiff})max heap per file for bsdiff" \
91 "(50th 90th 100th)"
94 main "${@}"