summaryrefslogtreecommitdiff
path: root/scripts/contrib
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2015-08-30 19:16:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-12 22:47:06 +0100
commit29fa8ee01ef3254272bcbdd13a8c7244548639a3 (patch)
treedba1d9d0fd6c144cc79ab64711ca83e7d14282d2 /scripts/contrib
parentb99640c89f067866b264f4ee4030fae4c2f338c0 (diff)
downloadopenembedded-core-29fa8ee01ef3254272bcbdd13a8c7244548639a3.tar.gz
openembedded-core-29fa8ee01ef3254272bcbdd13a8c7244548639a3.tar.bz2
openembedded-core-29fa8ee01ef3254272bcbdd13a8c7244548639a3.zip
buildstats: Outputs 'task recipe elapsed-time' from each buildstats' recipe
Given a 'buildstats' path (created by bitbake when setting USER_CLASSES ?= "buildstats" on local.conf) and task names, outputs '<task> <recipe> <elapsed time>' for all recipes. Elapsed times are in seconds, and task should be given without the 'do_' prefix. Some useful pipelines 1. Tasks with largest elapsed times $ buildstats.sh -b <buildstats> | sort -k3 -n -r | head do_compile perl-5.20.0-r1 221.82 do_configure gettext-native-0.19.4-r0 140.34 do_compile openssl-native-1.0.2a-r0 107.48 do_compile openssl-1.0.2a-r0 102.10 do_configure perl-native-5.20.0-r0 90.70 do_configure gettext-0.19.4-r0 88.17 do_compile gcc-cross-i586-4.9.2-r0 83.98 do_configure m4-native-1.4.17-r0 83.44 do_compile qemu-native-2.2.0-r1 71.69 do_compile glibc-2.21-r0 60.88 2. Min, max, sum per task $ buildstats.sh | datamash -t' ' -g1 min 3 max 3 sum 3 | sort -k4 -n -r do_configure 0.03 140.34 1968.66 do_compile 0.01 221.82 1664.44 do_install 0.03 40.31 330.45 do_populate_sysroot 0.11 34.45 229.23 do_unpack 0.01 36.1 193.54 do_patch 0.01 9.2 62.07 do_fetch 0.01 6.66 32.13 do_populate_lic 0.09 1.65 30.7 Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/contrib')
-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 @@
+#!/bin/bash
+#
+# Copyright (c) 2011, Intel Corporation.
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# DESCRIPTION
+# Given a 'buildstats' path (created by bitbake when setting
+# USER_CLASSES ?= "buildstats" on local.conf) and task names, outputs
+# '<task> <recipe> <elapsed time>' for all recipes. Elapsed times are in
+# seconds, and task should be given without the 'do_' prefix.
+#
+# Some useful pipelines
+#
+# 1. Tasks with largest elapsed times
+# $ buildstats.sh -b <buildstats> | sort -k3 -n -r | head
+#
+# 2. Min, max, sum per task (in needs GNU datamash)
+# $ buildstats.sh -b <buildstats> | datamash -t' ' -g1 min 3 max 3 sum 3 | sort -k4 -n -r
+#
+# AUTHORS
+# Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
+#
+BS_DIR="tmp/buildstats"
+TASKS="compile:configure:fetch:install:patch:populate_lic:populate_sysroot:unpack"
+
+function usage {
+CMD=$(basename $0)
+cat <<EOM
+Usage: $CMD [-b buildstats_dir] [-t do_task]
+ -b buildstats The path where the folder resides
+ (default: "$BS_DIR")
+ -t tasks The tasks to be computed
+ (default: "$TASKS")
+ -h Display this help message
+EOM
+}
+
+# Parse and validate arguments
+while getopts "b:t:h" OPT; do
+ case $OPT in
+ b)
+ BS_DIR="$OPTARG"
+ ;;
+ t)
+ TASKS="$OPTARG"
+ ;;
+ h)
+ usage
+ exit 0
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+# Ensure the buildstats folder exists
+if [ ! -d "$BS_DIR" ]; then
+ echo "ERROR: $BS_DIR does not exist"
+ usage
+ exit 1
+fi
+
+RECIPE_FIELD=1
+TIME_FIELD=4
+
+tasks=(${TASKS//:/ })
+for task in "${tasks[@]}"; do
+ task="do_${task}"
+ for file in $(find ${BS_DIR} -type f -name ${task}); do
+ recipe=$(sed -n -e "/$task/p" ${file} | cut -d ':' -f${RECIPE_FIELD})
+ time=$(sed -n -e "/$task/p" ${file} | cut -d ':' -f${TIME_FIELD} | cut -d ' ' -f2)
+ echo "${task} ${recipe} ${time}"
+ done
+done