collect_pprof_data.sh revision 058aae85dcfb12049ef90137915ec7e981288569
1#!/bin/bash
2
3# Copyright 2016 The Chromium OS 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.
6# Collects the pprof tree and top outputs.
7# All the local_cwp symbolized profiles are taken from the
8# local_cwp_results_path.
9# The pprof top output is stored in the pprof_top_results_path and the pprof
10# tree output is stored in the pprof_tree_results_path.
11
12set -e
13
14if [ "$#" -ne 3 ]; then
15  echo "USAGE: collect_pprof_data.sh local_cwp_results_path " \
16    "pprof_top_results_path pprof_tree_results_path"
17  exit 1
18fi
19
20readonly LOCAL_CWP_RESULTS_PATH=$1
21readonly PPROF_TOP_RESULTS_PATH=$2
22readonly PPROF_TREE_RESULTS_PATH=$3
23readonly SYMBOLIZED_PROFILES=`ls $LOCAL_CWP_RESULTS_PATH`
24
25for symbolized_profile in "${SYMBOLIZED_PROFILES[@]}"
26do
27  pprof --top "$LOCAL_CWP_RESULTS_PATH/${symbolized_profile}" > \
28    "$PPROF_TOP_RESULTS_PATH/${symbolized_profile}.pprof"
29  if [ $? -ne 0 ]; then
30    echo "Failed to extract the pprof top output for the $symbolized_profile."
31    continue
32  fi
33
34  pprof --tree "$LOCAL_CWP_RESULTS_PATH/${symbolized_profile}" > \
35    "$PPROF_TREE_RESULTS_PATH/${symbolized_profile}.pprof"
36  if [ $? -ne 0 ]; then
37    echo "Failed to extract the pprof tree output for the " \
38      "$symbolized_profile."
39    continue
40  fi
41done
42