summaryrefslogtreecommitdiffstats
path: root/scripts/contrib
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2016-11-15 15:19:53 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-30 15:48:05 +0000
commit70f99b427b9a0d691eacca7d4757840f8fd1634d (patch)
tree86f31e9c1366306f194609ddbf11fa69e4afbab9 /scripts/contrib
parentdc7f4a5bf8d99280ef67301008b9878dbb43d05b (diff)
downloadpoky-70f99b427b9a0d691eacca7d4757840f8fd1634d.tar.gz
bb-perf: plot histograms base on buildstats data
Scripts that produces script data to be consumed by gnuplot. There are two possible plots depending if either the -S parameter is present or not: * without -S: Produces a histogram listing top N recipes/tasks versus stats. The first stat defined in the -s parameter is the one taken into account for ranking * -S: Produces a histogram listing tasks versus stats. In this case, the value of each stat is the sum for that particular stat in all recipes found. Stats values are in descending order defined by the first stat defined on -s EXAMPLES 1. Top recipes' tasks taking into account utime $ buildstats-plot.sh -s utime | gnuplot -p 2. Tasks versus utime:stime $ buildstats-plot.sh -s utime:stime -S | gnuplot -p 3. Tasks versus IO write_bytes:IO read_bytes $ buildstats-plot.sh -s 'IO write_bytes:IO read_bytes' -S | gnuplot -p (From OE-Core rev: 74408c19fba89de54c093fccf65b3a072d6a197b) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/contrib')
-rwxr-xr-xscripts/contrib/bb-perf/buildstats-plot.sh157
1 files changed, 157 insertions, 0 deletions
diff --git a/scripts/contrib/bb-perf/buildstats-plot.sh b/scripts/contrib/bb-perf/buildstats-plot.sh
new file mode 100755
index 0000000000..7e8ae0410e
--- /dev/null
+++ b/scripts/contrib/bb-perf/buildstats-plot.sh
@@ -0,0 +1,157 @@
1#!/usr/bin/env bash
2#
3# Copyright (c) 2011, Intel Corporation.
4# All rights reserved.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
20# DESCRIPTION
21#
22# Produces script data to be consumed by gnuplot. There are two possible plots
23# depending if either the -S parameter is present or not:
24#
25# * without -S: Produces a histogram listing top N recipes/tasks versus
26# stats. The first stat defined in the -s parameter is the one taken
27# into account for ranking
28# * -S: Produces a histogram listing tasks versus stats. In this case,
29# the value of each stat is the sum for that particular stat in all recipes found.
30# Stats values are in descending order defined by the first stat defined on -s
31#
32# EXAMPLES
33#
34# 1. Top recipes' tasks taking into account utime
35#
36# $ buildstats-plot.sh -s utime | gnuplot -p
37#
38# 2. Tasks versus utime:stime
39#
40# $ buildstats-plot.sh -s utime:stime -S | gnuplot -p
41#
42# 3. Tasks versus IO write_bytes:IO read_bytes
43#
44# $ buildstats-plot.sh -s 'IO write_bytes:IO read_bytes' -S | gnuplot -p
45#
46# AUTHORS
47# Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
48#
49
50set -o nounset
51set -o errexit
52
53BS_DIR="tmp/buildstats"
54N=10
55STATS="utime"
56SUM=""
57OUTDATA_FILE="$PWD/buildstats-plot.out"
58
59function usage {
60 CMD=$(basename $0)
61 cat <<EOM
62Usage: $CMD [-b buildstats_dir] [-t do_task]
63 -b buildstats The path where the folder resides
64 (default: "$BS_DIR")
65 -n N Top N recipes to display. Ignored if -S is present
66 (default: "$N")
67 -s stats The stats to be matched. If more that one stat, units
68 should be the same because data is plot as histogram.
69 (see buildstats.sh -h for all options) or any other defined
70 (build)stat separated by colons, i.e. stime:utime
71 (default: "$STATS")
72 -S Sum values for a particular stat for found recipes
73 -o Output data file.
74 (default: "$OUTDATA_FILE")
75 -h Display this help message
76EOM
77}
78
79# Parse and validate arguments
80while getopts "b:n:s:o:Sh" OPT; do
81 case $OPT in
82 b)
83 BS_DIR="$OPTARG"
84 ;;
85 n)
86 N="$OPTARG"
87 ;;
88 s)
89 STATS="$OPTARG"
90 ;;
91 S)
92 SUM="y"
93 ;;
94 o)
95 OUTDATA_FILE="$OPTARG"
96 ;;
97 h)
98 usage
99 exit 0
100 ;;
101 *)
102 usage
103 exit 1
104 ;;
105 esac
106done
107
108# Get number of stats
109IFS=':'; statsarray=(${STATS}); unset IFS
110nstats=${#statsarray[@]}
111
112# Get script folder, use to run buildstats.sh
113CD=$(dirname $0)
114
115# Parse buildstats recipes to produce a single table
116OUTBUILDSTATS="$PWD/buildstats.log"
117$CD/buildstats.sh -H -s "$STATS" -H > $OUTBUILDSTATS
118
119# Get headers
120HEADERS=$(cat $OUTBUILDSTATS | sed -n -e '1s/ /-/g' -e '1s/:/ /gp')
121
122echo -e "set boxwidth 0.9 relative"
123echo -e "set style data histograms"
124echo -e "set style fill solid 1.0 border lt -1"
125echo -e "set xtics rotate by 45 right"
126
127# Get output data
128if [ -z "$SUM" ]; then
129 cat $OUTBUILDSTATS | sed -e '1d' | sort -k3 -n -r | head -$N > $OUTDATA_FILE
130 # include task at recipe column
131 sed -i -e "1i\
132${HEADERS}" $OUTDATA_FILE
133 echo -e "set title \"Top task/recipes\""
134 echo -e "plot for [COL=3:`expr 3 + ${nstats} - 1`] '${OUTDATA_FILE}' using COL:xtic(stringcolumn(1).' '.stringcolumn(2)) title columnheader(COL)"
135else
136
137 # Construct datatamash sum argument (sum 3 sum 4 ...)
138 declare -a sumargs
139 j=0
140 for i in `seq $nstats`; do
141 sumargs[j]=sum; j=$(( $j + 1 ))
142 sumargs[j]=`expr 3 + $i - 1`; j=$(( $j + 1 ))
143 done
144
145 # Do the processing with datamash
146 cat $OUTBUILDSTATS | sed -e '1d' | datamash -t ' ' -g1 ${sumargs[*]} | sort -k2 -n -r > $OUTDATA_FILE
147
148 # Include headers into resulted file, so we can include gnuplot xtics
149 HEADERS=$(echo $HEADERS | sed -e 's/recipe//1')
150 sed -i -e "1i\
151${HEADERS}" $OUTDATA_FILE
152
153 # Plot
154 echo -e "set title \"Sum stats values per task for all recipes\""
155 echo -e "plot for [COL=2:`expr 2 + ${nstats} - 1`] '${OUTDATA_FILE}' using COL:xtic(1) title columnheader(COL)"
156fi
157