#!/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 'buildstats' data (generate by bitbake when setting # USER_CLASSES ?= "buildstats" on local.conf), task names and a stats values # (these are the ones preset on the buildstats files), outputs # ' ... '. The units are the ones # defined at buildstats, which in turn takes data from /proc/[pid] files # # Some useful pipelines # # 1. Tasks with largest stime (Amount of time that this process has been scheduled # in kernel mode) values # $ buildstats.sh -b -s stime | sort -k3 -n -r | head # # 2. Min, max, sum utime (Amount of time that this process has been scheduled # in user mode) per task (in needs GNU datamash) # $ buildstats.sh -b -s utime | datamash -t' ' -g1 min 3 max 3 sum 3 | sort -k4 -n -r # # AUTHORS # Leonardo Sandoval # # Stats, by type TIME="utime:stime:cutime:cstime" IO="IO wchar:IO write_bytes:IO syscr:IO read_bytes:IO rchar:IO syscw:IO cancelled_write_bytes" RUSAGE="rusage ru_utime:rusage ru_stime:rusage ru_maxrss:rusage ru_minflt:rusage ru_majflt:\ rusage ru_inblock:rusage ru_oublock:rusage ru_nvcsw:rusage ru_nivcsw" CHILD_RUSAGE="Child rusage ru_utime:Child rusage ru_stime:Child rusage ru_maxrss:Child rusage ru_minflt:\ Child rusage ru_majflt:Child rusage ru_inblock:Child rusage ru_oublock:Child rusage ru_nvcsw:\ Child rusage ru_nivcsw" BS_DIR="tmp/buildstats" TASKS="compile:configure:fetch:install:patch:populate_lic:populate_sysroot:unpack" STATS="$TIME" HEADER="" # No header by default function usage { CMD=$(basename $0) cat <