summaryrefslogtreecommitdiffstats
path: root/scripts/contrib/bb-perf
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/contrib/bb-perf')
-rwxr-xr-xscripts/contrib/bb-perf/buildstats.sh90
1 files changed, 90 insertions, 0 deletions
diff --git a/scripts/contrib/bb-perf/buildstats.sh b/scripts/contrib/bb-perf/buildstats.sh
new file mode 100755
index 0000000000..96158a9650
--- /dev/null
+++ b/scripts/contrib/bb-perf/buildstats.sh
@@ -0,0 +1,90 @@
1#!/bin/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# Given a 'buildstats' path (created by bitbake when setting
22# USER_CLASSES ?= "buildstats" on local.conf) and task names, outputs
23# '<task> <recipe> <elapsed time>' for all recipes. Elapsed times are in
24# seconds, and task should be given without the 'do_' prefix.
25#
26# Some useful pipelines
27#
28# 1. Tasks with largest elapsed times
29# $ buildstats.sh -b <buildstats> | sort -k3 -n -r | head
30#
31# 2. Min, max, sum per task (in needs GNU datamash)
32# $ buildstats.sh -b <buildstats> | datamash -t' ' -g1 min 3 max 3 sum 3 | sort -k4 -n -r
33#
34# AUTHORS
35# Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
36#
37BS_DIR="tmp/buildstats"
38TASKS="compile:configure:fetch:install:patch:populate_lic:populate_sysroot:unpack"
39
40function usage {
41CMD=$(basename $0)
42cat <<EOM
43Usage: $CMD [-b buildstats_dir] [-t do_task]
44 -b buildstats The path where the folder resides
45 (default: "$BS_DIR")
46 -t tasks The tasks to be computed
47 (default: "$TASKS")
48 -h Display this help message
49EOM
50}
51
52# Parse and validate arguments
53while getopts "b:t:h" OPT; do
54 case $OPT in
55 b)
56 BS_DIR="$OPTARG"
57 ;;
58 t)
59 TASKS="$OPTARG"
60 ;;
61 h)
62 usage
63 exit 0
64 ;;
65 *)
66 usage
67 exit 1
68 ;;
69 esac
70done
71
72# Ensure the buildstats folder exists
73if [ ! -d "$BS_DIR" ]; then
74 echo "ERROR: $BS_DIR does not exist"
75 usage
76 exit 1
77fi
78
79RECIPE_FIELD=1
80TIME_FIELD=4
81
82tasks=(${TASKS//:/ })
83for task in "${tasks[@]}"; do
84 task="do_${task}"
85 for file in $(find ${BS_DIR} -type f -name ${task}); do
86 recipe=$(sed -n -e "/$task/p" ${file} | cut -d ':' -f${RECIPE_FIELD})
87 time=$(sed -n -e "/$task/p" ${file} | cut -d ':' -f${TIME_FIELD} | cut -d ' ' -f2)
88 echo "${task} ${recipe} ${time}"
89 done
90done