#!/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 memory metrics for run_apply_test source "$(dirname ${0})/stress_test_common" compute_percentiles() { if [ -z "${1}" ]; then return; fi local pctls=".5 .9 1" local lines=$(cat ${1} | wc -l) for p in $pctls; do local count="$(echo "${lines} * $p" | bc -lq | cut -d. -f1)" local bytes=$(cat ${1} \ | cut -d' ' -f2 \ | sort -n \ | head -n$count \ | tail -n1) echo -n "$((bytes / 1000000))MB " done } main() { if [ $# -lt 1 ]; then cat < "${metrics_tmp}" mv "${metrics_tmp}" "${metrics}" fi echo "$(compute_percentiles ${metrics})max heap per file for Courgette" \ "(50th 90th 100th)" local metrics_bsdiff="${dir}/mem_per_file_bsdiff.txt" if [ ! -f "${metrics_bsdiff}" ]; then local metrics_bsdiff_tmp="${metrics_bsdiff}.tmp" echo "computing usage percentiles for bsdiff. this may take a while..." find "${metrics_dir}" \ | grep "\.bsdiff_mem$" \ | while read i; do local bsdiff_mem="${i}" echo -n "$bsdiff_mem " cat $bsdiff_mem \ | grep "mem_heap_B" \ | cut -d= -f2 \ | sort -nr \ | head -n1 done | sort -k2 -n > "${metrics_bsdiff_tmp}" mv "${metrics_bsdiff_tmp}" "${metrics_bsdiff}" fi echo "$(compute_percentiles ${metrics_bsdiff})max heap per file for bsdiff" \ "(50th 90th 100th)" } main "${@}"