diff options
Diffstat (limited to 'scripts/contrib/bb-perf')
| -rwxr-xr-x | scripts/contrib/bb-perf/bb-matrix-plot.sh | 124 | ||||
| -rwxr-xr-x | scripts/contrib/bb-perf/bb-matrix.sh | 66 | ||||
| -rwxr-xr-x | scripts/contrib/bb-perf/buildstats-plot.sh | 160 | ||||
| -rwxr-xr-x | scripts/contrib/bb-perf/buildstats.sh | 167 |
4 files changed, 0 insertions, 517 deletions
diff --git a/scripts/contrib/bb-perf/bb-matrix-plot.sh b/scripts/contrib/bb-perf/bb-matrix-plot.sh deleted file mode 100755 index 6672189c95..0000000000 --- a/scripts/contrib/bb-perf/bb-matrix-plot.sh +++ /dev/null | |||
| @@ -1,124 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2011, Intel Corporation. | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | # | ||
| 7 | # DESCRIPTION | ||
| 8 | # This script operates on the .dat file generated by bb-matrix.sh. It tolerates | ||
| 9 | # the header by skipping the first line, but error messages and bad data records | ||
| 10 | # need to be removed first. It will generate three views of the plot, and leave | ||
| 11 | # an interactive view open for further analysis. | ||
| 12 | # | ||
| 13 | # AUTHORS | ||
| 14 | # Darren Hart <dvhart@linux.intel.com> | ||
| 15 | # | ||
| 16 | |||
| 17 | # Setup the defaults | ||
| 18 | DATFILE="bb-matrix.dat" | ||
| 19 | XLABEL="BB\\\\_NUMBER\\\\_THREADS" | ||
| 20 | YLABEL="PARALLEL\\\\_MAKE" | ||
| 21 | FIELD=3 | ||
| 22 | DEF_TITLE="Elapsed Time (seconds)" | ||
| 23 | PM3D_FRAGMENT="unset surface; set pm3d at s hidden3d 100" | ||
| 24 | SIZE="640,480" | ||
| 25 | |||
| 26 | function usage { | ||
| 27 | CMD=$(basename $0) | ||
| 28 | cat <<EOM | ||
| 29 | Usage: $CMD [-d datfile] [-f field] [-h] [-t title] [-w] | ||
| 30 | -d datfile The data file generated by bb-matrix.sh (default: $DATFILE) | ||
| 31 | -f field The field index to plot as the Z axis from the data file | ||
| 32 | (default: $FIELD, "$DEF_TITLE") | ||
| 33 | -h Display this help message | ||
| 34 | -s W,H PNG and window size in pixels (default: $SIZE) | ||
| 35 | -t title The title to display, should describe the field (-f) and units | ||
| 36 | (default: "$DEF_TITLE") | ||
| 37 | -w Render the plot as wireframe with a 2D colormap projected on the | ||
| 38 | XY plane rather than as the texture for the surface | ||
| 39 | EOM | ||
| 40 | } | ||
| 41 | |||
| 42 | # Parse and validate arguments | ||
| 43 | while getopts "d:f:hs:t:w" OPT; do | ||
| 44 | case $OPT in | ||
| 45 | d) | ||
| 46 | DATFILE="$OPTARG" | ||
| 47 | ;; | ||
| 48 | f) | ||
| 49 | FIELD="$OPTARG" | ||
| 50 | ;; | ||
| 51 | h) | ||
| 52 | usage | ||
| 53 | exit 0 | ||
| 54 | ;; | ||
| 55 | s) | ||
| 56 | SIZE="$OPTARG" | ||
| 57 | ;; | ||
| 58 | t) | ||
| 59 | TITLE="$OPTARG" | ||
| 60 | ;; | ||
| 61 | w) | ||
| 62 | PM3D_FRAGMENT="set pm3d at b" | ||
| 63 | W="-w" | ||
| 64 | ;; | ||
| 65 | *) | ||
| 66 | usage | ||
| 67 | exit 1 | ||
| 68 | ;; | ||
| 69 | esac | ||
| 70 | done | ||
| 71 | |||
| 72 | # Ensure the data file exists | ||
| 73 | if [ ! -f "$DATFILE" ]; then | ||
| 74 | echo "ERROR: $DATFILE does not exist" | ||
| 75 | usage | ||
| 76 | exit 1 | ||
| 77 | fi | ||
| 78 | PLOT_BASENAME=${DATFILE%.*}-f$FIELD$W | ||
| 79 | |||
| 80 | # Set a sane title | ||
| 81 | # TODO: parse the header and define titles for each format parameter for TIME(1) | ||
| 82 | if [ -z "$TITLE" ]; then | ||
| 83 | if [ ! "$FIELD" == "3" ]; then | ||
| 84 | TITLE="Field $FIELD" | ||
| 85 | else | ||
| 86 | TITLE="$DEF_TITLE" | ||
| 87 | fi | ||
| 88 | fi | ||
| 89 | |||
| 90 | # Determine the dgrid3d mesh dimensions size | ||
| 91 | MIN=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 1 | sed 's/^0*//' | sort -n | uniq | head -n1) | ||
| 92 | MAX=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 1 | sed 's/^0*//' | sort -n | uniq | tail -n1) | ||
| 93 | BB_CNT=$[${MAX} - $MIN + 1] | ||
| 94 | MIN=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 2 | sed 's/^0*//' | sort -n | uniq | head -n1) | ||
| 95 | MAX=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 2 | sed 's/^0*//' | sort -n | uniq | tail -n1) | ||
| 96 | PM_CNT=$[${MAX} - $MIN + 1] | ||
| 97 | |||
| 98 | |||
| 99 | (cat <<EOF | ||
| 100 | set title "$TITLE" | ||
| 101 | set xlabel "$XLABEL" | ||
| 102 | set ylabel "$YLABEL" | ||
| 103 | set style line 100 lt 5 lw 1.5 | ||
| 104 | $PM3D_FRAGMENT | ||
| 105 | set dgrid3d $PM_CNT,$BB_CNT splines | ||
| 106 | set ticslevel 0.2 | ||
| 107 | |||
| 108 | set term png size $SIZE | ||
| 109 | set output "$PLOT_BASENAME.png" | ||
| 110 | splot "$DATFILE" every ::1 using 1:2:$FIELD with lines ls 100 | ||
| 111 | |||
| 112 | set view 90,0 | ||
| 113 | set output "$PLOT_BASENAME-bb.png" | ||
| 114 | replot | ||
| 115 | |||
| 116 | set view 90,90 | ||
| 117 | set output "$PLOT_BASENAME-pm.png" | ||
| 118 | replot | ||
| 119 | |||
| 120 | set view 60,30 | ||
| 121 | set term wxt size $SIZE | ||
| 122 | replot | ||
| 123 | EOF | ||
| 124 | ) | gnuplot --persist | ||
diff --git a/scripts/contrib/bb-perf/bb-matrix.sh b/scripts/contrib/bb-perf/bb-matrix.sh deleted file mode 100755 index b1fff0f344..0000000000 --- a/scripts/contrib/bb-perf/bb-matrix.sh +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2011, Intel Corporation. | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | # | ||
| 7 | # DESCRIPTION | ||
| 8 | # This script runs BB_CMD (typically building core-image-sato) for all | ||
| 9 | # combincations of BB_RANGE and PM_RANGE values. It saves off all the console | ||
| 10 | # logs, the buildstats directories, and creates a bb-pm-runtime.dat file which | ||
| 11 | # can be used to postprocess the results with a plotting tool, spreadsheet, etc. | ||
| 12 | # Before running this script, it is recommended that you pre-download all the | ||
| 13 | # necessary sources by performing the BB_CMD once manually. It is also a good | ||
| 14 | # idea to disable cron to avoid runtime variations caused by things like the | ||
| 15 | # locate process. Be sure to sanitize the dat file prior to post-processing as | ||
| 16 | # it may contain error messages or bad runs that should be removed. | ||
| 17 | # | ||
| 18 | # AUTHORS | ||
| 19 | # Darren Hart <dvhart@linux.intel.com> | ||
| 20 | # | ||
| 21 | |||
| 22 | # The following ranges are appropriate for a 4 core system with 8 logical units | ||
| 23 | # Use leading 0s to ensure all digits are the same string length, this results | ||
| 24 | # in nice log file names and columnar dat files. | ||
| 25 | BB_RANGE="04 05 06 07 08 09 10 11 12 13 14 15 16" | ||
| 26 | PM_RANGE="04 05 06 07 08 09 10 11 12 13 14 15 16" | ||
| 27 | |||
| 28 | DATADIR="bb-matrix-$$" | ||
| 29 | BB_CMD="bitbake core-image-minimal" | ||
| 30 | RUNTIME_LOG="$DATADIR/bb-matrix.dat" | ||
| 31 | |||
| 32 | # See TIME(1) for a description of the time format parameters | ||
| 33 | # The following all report 0: W K r s t w | ||
| 34 | TIME_STR="%e %S %U %P %c %w %R %F %M %x" | ||
| 35 | |||
| 36 | # Prepare the DATADIR | ||
| 37 | mkdir $DATADIR | ||
| 38 | if [ $? -ne 0 ]; then | ||
| 39 | echo "Failed to create $DATADIR." | ||
| 40 | exit 1 | ||
| 41 | fi | ||
| 42 | |||
| 43 | # Add a simple header | ||
| 44 | echo "BB PM $TIME_STR" > $RUNTIME_LOG | ||
| 45 | for BB in $BB_RANGE; do | ||
| 46 | for PM in $PM_RANGE; do | ||
| 47 | RUNDIR="$DATADIR/$BB-$PM-build" | ||
| 48 | mkdir $RUNDIR | ||
| 49 | BB_LOG=$RUNDIR/$BB-$PM-bitbake.log | ||
| 50 | date | ||
| 51 | echo "BB=$BB PM=$PM Logging to $BB_LOG" | ||
| 52 | |||
| 53 | echo -n " Preparing the work directory... " | ||
| 54 | rm -rf pseudodone tmp sstate-cache tmp-eglibc &> /dev/null | ||
| 55 | echo "done" | ||
| 56 | |||
| 57 | # Export the variables under test and run the bitbake command | ||
| 58 | # Strip any leading zeroes before passing to bitbake | ||
| 59 | export BB_NUMBER_THREADS=$(echo $BB | sed 's/^0*//') | ||
| 60 | export PARALLEL_MAKE="-j $(echo $PM | sed 's/^0*//')" | ||
| 61 | /usr/bin/time -f "$BB $PM $TIME_STR" -a -o $RUNTIME_LOG $BB_CMD &> $BB_LOG | ||
| 62 | |||
| 63 | echo " $(tail -n1 $RUNTIME_LOG)" | ||
| 64 | cp -a tmp/buildstats $RUNDIR/$BB-$PM-buildstats | ||
| 65 | done | ||
| 66 | done | ||
diff --git a/scripts/contrib/bb-perf/buildstats-plot.sh b/scripts/contrib/bb-perf/buildstats-plot.sh deleted file mode 100755 index 45c27d0b97..0000000000 --- a/scripts/contrib/bb-perf/buildstats-plot.sh +++ /dev/null | |||
| @@ -1,160 +0,0 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2011, Intel Corporation. | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | # | ||
| 7 | # DESCRIPTION | ||
| 8 | # | ||
| 9 | # Produces script data to be consumed by gnuplot. There are two possible plots | ||
| 10 | # depending if either the -S parameter is present or not: | ||
| 11 | # | ||
| 12 | # * without -S: Produces a histogram listing top N recipes/tasks versus | ||
| 13 | # stats. The first stat defined in the -s parameter is the one taken | ||
| 14 | # into account for ranking | ||
| 15 | # * -S: Produces a histogram listing tasks versus stats. In this case, | ||
| 16 | # the value of each stat is the sum for that particular stat in all recipes found. | ||
| 17 | # Stats values are in descending order defined by the first stat defined on -s | ||
| 18 | # | ||
| 19 | # EXAMPLES | ||
| 20 | # | ||
| 21 | # 1. Top recipes' tasks taking into account utime | ||
| 22 | # | ||
| 23 | # $ buildstats-plot.sh -s utime | gnuplot -p | ||
| 24 | # | ||
| 25 | # 2. Tasks versus utime:stime | ||
| 26 | # | ||
| 27 | # $ buildstats-plot.sh -s utime:stime -S | gnuplot -p | ||
| 28 | # | ||
| 29 | # 3. Tasks versus IO write_bytes:IO read_bytes | ||
| 30 | # | ||
| 31 | # $ buildstats-plot.sh -s 'IO write_bytes:IO read_bytes' -S | gnuplot -p | ||
| 32 | # | ||
| 33 | # AUTHORS | ||
| 34 | # Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | ||
| 35 | # | ||
| 36 | |||
| 37 | set -o nounset | ||
| 38 | set -o errexit | ||
| 39 | |||
| 40 | BS_DIR="tmp/buildstats" | ||
| 41 | N=10 | ||
| 42 | RECIPE="" | ||
| 43 | TASKS="compile:configure:fetch:install:patch:populate_lic:populate_sysroot:unpack" | ||
| 44 | STATS="utime" | ||
| 45 | ACCUMULATE="" | ||
| 46 | SUM="" | ||
| 47 | OUTDATA_FILE="$PWD/buildstats-plot.out" | ||
| 48 | |||
| 49 | function usage { | ||
| 50 | CMD=$(basename $0) | ||
| 51 | cat <<EOM | ||
| 52 | Usage: $CMD [-b buildstats_dir] [-t do_task] | ||
| 53 | -b buildstats The path where the folder resides | ||
| 54 | (default: "$BS_DIR") | ||
| 55 | -n N Top N recipes to display. Ignored if -S is present | ||
| 56 | (default: "$N") | ||
| 57 | -r recipe The recipe mask to be searched | ||
| 58 | -t tasks The tasks to be computed | ||
| 59 | (default: "$TASKS") | ||
| 60 | -s stats The stats to be matched. If more that one stat, units | ||
| 61 | should be the same because data is plot as histogram. | ||
| 62 | (see buildstats.sh -h for all options) or any other defined | ||
| 63 | (build)stat separated by colons, i.e. stime:utime | ||
| 64 | (default: "$STATS") | ||
| 65 | -a Accumulate all stats values for found recipes | ||
| 66 | -S Sum values for a particular stat for found recipes | ||
| 67 | -o Output data file. | ||
| 68 | (default: "$OUTDATA_FILE") | ||
| 69 | -h Display this help message | ||
| 70 | EOM | ||
| 71 | } | ||
| 72 | |||
| 73 | # Parse and validate arguments | ||
| 74 | while getopts "b:n:r:t:s:o:aSh" OPT; do | ||
| 75 | case $OPT in | ||
| 76 | b) | ||
| 77 | BS_DIR="$OPTARG" | ||
| 78 | ;; | ||
| 79 | n) | ||
| 80 | N="$OPTARG" | ||
| 81 | ;; | ||
| 82 | r) | ||
| 83 | RECIPE="-r $OPTARG" | ||
| 84 | ;; | ||
| 85 | t) | ||
| 86 | TASKS="$OPTARG" | ||
| 87 | ;; | ||
| 88 | s) | ||
| 89 | STATS="$OPTARG" | ||
| 90 | ;; | ||
| 91 | a) | ||
| 92 | ACCUMULATE="-a" | ||
| 93 | ;; | ||
| 94 | S) | ||
| 95 | SUM="y" | ||
| 96 | ;; | ||
| 97 | o) | ||
| 98 | OUTDATA_FILE="$OPTARG" | ||
| 99 | ;; | ||
| 100 | h) | ||
| 101 | usage | ||
| 102 | exit 0 | ||
| 103 | ;; | ||
| 104 | *) | ||
| 105 | usage | ||
| 106 | exit 1 | ||
| 107 | ;; | ||
| 108 | esac | ||
| 109 | done | ||
| 110 | |||
| 111 | # Get number of stats | ||
| 112 | IFS=':'; statsarray=(${STATS}); unset IFS | ||
| 113 | nstats=${#statsarray[@]} | ||
| 114 | |||
| 115 | # Get script folder, use to run buildstats.sh | ||
| 116 | CD=$(dirname $0) | ||
| 117 | |||
| 118 | # Parse buildstats recipes to produce a single table | ||
| 119 | OUTBUILDSTATS="$PWD/buildstats.log" | ||
| 120 | $CD/buildstats.sh -b "$BS_DIR" -s "$STATS" -t "$TASKS" $RECIPE $ACCUMULATE -H > $OUTBUILDSTATS | ||
| 121 | |||
| 122 | # Get headers | ||
| 123 | HEADERS=$(cat $OUTBUILDSTATS | sed -n -e 's/\(.*\)/"\1"/' -e '1s/ /\\\\\\\\ /g' -e 's/_/\\\\\\\\_/g' -e '1s/:/" "/gp') | ||
| 124 | |||
| 125 | echo -e "set boxwidth 0.9 relative" | ||
| 126 | echo -e "set style data histograms" | ||
| 127 | echo -e "set style fill solid 1.0 border lt -1" | ||
| 128 | echo -e "set xtics rotate by 45 right" | ||
| 129 | |||
| 130 | # Get output data | ||
| 131 | if [ -z "$SUM" ]; then | ||
| 132 | cat $OUTBUILDSTATS | sed -e '1d' -e 's/_/\\\\_/g' | sort -k3 -n -r | head -$N > $OUTDATA_FILE | ||
| 133 | # include task at recipe column | ||
| 134 | sed -i -e "1i\ | ||
| 135 | ${HEADERS}" $OUTDATA_FILE | ||
| 136 | echo -e "set title \"Top task/recipes\"" | ||
| 137 | echo -e "plot for [COL=3:`expr 3 + ${nstats} - 1`] '${OUTDATA_FILE}' using COL:xtic(stringcolumn(1).' '.stringcolumn(2)) title columnheader(COL)" | ||
| 138 | else | ||
| 139 | |||
| 140 | # Construct datatamash sum argument (sum 3 sum 4 ...) | ||
| 141 | declare -a sumargs | ||
| 142 | j=0 | ||
| 143 | for i in `seq $nstats`; do | ||
| 144 | sumargs[j]=sum; j=$(( $j + 1 )) | ||
| 145 | sumargs[j]=`expr 3 + $i - 1`; j=$(( $j + 1 )) | ||
| 146 | done | ||
| 147 | |||
| 148 | # Do the processing with datamash | ||
| 149 | cat $OUTBUILDSTATS | sed -e '1d' | datamash -t ' ' -g1 ${sumargs[*]} | sort -k2 -n -r > $OUTDATA_FILE | ||
| 150 | |||
| 151 | # Include headers into resulted file, so we can include gnuplot xtics | ||
| 152 | HEADERS=$(echo $HEADERS | sed -e 's/recipe//1') | ||
| 153 | sed -i -e "1i\ | ||
| 154 | ${HEADERS}" $OUTDATA_FILE | ||
| 155 | |||
| 156 | # Plot | ||
| 157 | echo -e "set title \"Sum stats values per task for all recipes\"" | ||
| 158 | echo -e "plot for [COL=2:`expr 2 + ${nstats} - 1`] '${OUTDATA_FILE}' using COL:xtic(1) title columnheader(COL)" | ||
| 159 | fi | ||
| 160 | |||
diff --git a/scripts/contrib/bb-perf/buildstats.sh b/scripts/contrib/bb-perf/buildstats.sh deleted file mode 100755 index e45cfc146d..0000000000 --- a/scripts/contrib/bb-perf/buildstats.sh +++ /dev/null | |||
| @@ -1,167 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2011, Intel Corporation. | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | # | ||
| 7 | # DESCRIPTION | ||
| 8 | # Given 'buildstats' data (generate by bitbake when setting | ||
| 9 | # USER_CLASSES ?= "buildstats" on local.conf), task names and a stats values | ||
| 10 | # (these are the ones preset on the buildstats files), outputs | ||
| 11 | # '<task> <recipe> <value_1> <value_2> ... <value_n>'. The units are the ones | ||
| 12 | # defined at buildstats, which in turn takes data from /proc/[pid] files | ||
| 13 | # | ||
| 14 | # Some useful pipelines | ||
| 15 | # | ||
| 16 | # 1. Tasks with largest stime (Amount of time that this process has been scheduled | ||
| 17 | # in kernel mode) values | ||
| 18 | # $ buildstats.sh -b <buildstats> -s stime | sort -k3 -n -r | head | ||
| 19 | # | ||
| 20 | # 2. Min, max, sum utime (Amount of time that this process has been scheduled | ||
| 21 | # in user mode) per task (in needs GNU datamash) | ||
| 22 | # $ buildstats.sh -b <buildstats> -s utime | datamash -t' ' -g1 min 3 max 3 sum 3 | sort -k4 -n -r | ||
| 23 | # | ||
| 24 | # AUTHORS | ||
| 25 | # Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | ||
| 26 | # | ||
| 27 | |||
| 28 | # Stats, by type | ||
| 29 | TIME="utime:stime:cutime:cstime" | ||
| 30 | IO="IO wchar:IO write_bytes:IO syscr:IO read_bytes:IO rchar:IO syscw:IO cancelled_write_bytes" | ||
| 31 | RUSAGE="rusage ru_utime:rusage ru_stime:rusage ru_maxrss:rusage ru_minflt:rusage ru_majflt:\ | ||
| 32 | rusage ru_inblock:rusage ru_oublock:rusage ru_nvcsw:rusage ru_nivcsw" | ||
| 33 | |||
| 34 | CHILD_RUSAGE="Child rusage ru_utime:Child rusage ru_stime:Child rusage ru_maxrss:Child rusage ru_minflt:\ | ||
| 35 | Child rusage ru_majflt:Child rusage ru_inblock:Child rusage ru_oublock:Child rusage ru_nvcsw:\ | ||
| 36 | Child rusage ru_nivcsw" | ||
| 37 | |||
| 38 | BS_DIR="tmp/buildstats" | ||
| 39 | RECIPE="" | ||
| 40 | TASKS="compile:configure:fetch:install:patch:populate_lic:populate_sysroot:unpack" | ||
| 41 | STATS="$TIME" | ||
| 42 | ACCUMULATE="" | ||
| 43 | HEADER="" # No header by default | ||
| 44 | |||
| 45 | function usage { | ||
| 46 | CMD=$(basename $0) | ||
| 47 | cat <<EOM | ||
| 48 | Usage: $CMD [-b buildstats_dir] [-t do_task] | ||
| 49 | -b buildstats The path where the folder resides | ||
| 50 | (default: "$BS_DIR") | ||
| 51 | -r recipe The recipe to be computed | ||
| 52 | -t tasks The tasks to be computed | ||
| 53 | (default: "$TASKS") | ||
| 54 | -s stats The stats to be matched. Options: TIME, IO, RUSAGE, CHILD_RUSAGE | ||
| 55 | or any other defined buildstat separated by colons, i.e. stime:utime | ||
| 56 | (default: "$STATS") | ||
| 57 | Default stat sets: | ||
| 58 | TIME=$TIME | ||
| 59 | IO=$IO | ||
| 60 | RUSAGE=$RUSAGE | ||
| 61 | CHILD_RUSAGE=$CHILD_RUSAGE | ||
| 62 | -a Accumulate all stats values for found recipes | ||
| 63 | -h Display this help message | ||
| 64 | EOM | ||
| 65 | } | ||
| 66 | |||
| 67 | # Parse and validate arguments | ||
| 68 | while getopts "b:r:t:s:aHh" OPT; do | ||
| 69 | case $OPT in | ||
| 70 | b) | ||
| 71 | BS_DIR="$OPTARG" | ||
| 72 | ;; | ||
| 73 | r) | ||
| 74 | RECIPE="$OPTARG" | ||
| 75 | ;; | ||
| 76 | t) | ||
| 77 | TASKS="$OPTARG" | ||
| 78 | ;; | ||
| 79 | s) | ||
| 80 | STATS="$OPTARG" | ||
| 81 | ;; | ||
| 82 | a) | ||
| 83 | ACCUMULATE="y" | ||
| 84 | ;; | ||
| 85 | H) | ||
| 86 | HEADER="y" | ||
| 87 | ;; | ||
| 88 | h) | ||
| 89 | usage | ||
| 90 | exit 0 | ||
| 91 | ;; | ||
| 92 | *) | ||
| 93 | usage | ||
| 94 | exit 1 | ||
| 95 | ;; | ||
| 96 | esac | ||
| 97 | done | ||
| 98 | |||
| 99 | # Ensure the buildstats folder exists | ||
| 100 | if [ ! -d "$BS_DIR" ]; then | ||
| 101 | echo "ERROR: $BS_DIR does not exist" | ||
| 102 | usage | ||
| 103 | exit 1 | ||
| 104 | fi | ||
| 105 | |||
| 106 | stats="" | ||
| 107 | IFS=":" | ||
| 108 | for stat in ${STATS}; do | ||
| 109 | case $stat in | ||
| 110 | TIME) | ||
| 111 | stats="${stats}:${TIME}" | ||
| 112 | ;; | ||
| 113 | IO) | ||
| 114 | stats="${stats}:${IO}" | ||
| 115 | ;; | ||
| 116 | RUSAGE) | ||
| 117 | stats="${stats}:${RUSAGE}" | ||
| 118 | ;; | ||
| 119 | CHILD_RUSAGE) | ||
| 120 | stats="${stats}:${CHILD_RUSAGE}" | ||
| 121 | ;; | ||
| 122 | *) | ||
| 123 | stats="${STATS}" | ||
| 124 | ;; | ||
| 125 | esac | ||
| 126 | done | ||
| 127 | |||
| 128 | # remove possible colon at the beginning | ||
| 129 | stats="$(echo "$stats" | sed -e 's/^://1')" | ||
| 130 | |||
| 131 | # Provide a header if required by the user | ||
| 132 | if [ -n "$HEADER" ] ; then | ||
| 133 | if [ -n "$ACCUMULATE" ]; then | ||
| 134 | echo "task:recipe:accumulated(${stats//:/;})" | ||
| 135 | else | ||
| 136 | echo "task:recipe:$stats" | ||
| 137 | fi | ||
| 138 | fi | ||
| 139 | |||
| 140 | for task in ${TASKS}; do | ||
| 141 | task="do_${task}" | ||
| 142 | for file in $(find ${BS_DIR} -type f -path *${RECIPE}*/${task} | awk 'BEGIN{ ORS=""; OFS=":" } { print $0,"" }'); do | ||
| 143 | recipe="$(basename $(dirname $file))" | ||
| 144 | times="" | ||
| 145 | for stat in ${stats}; do | ||
| 146 | [ -z "$stat" ] && { echo "empty stats"; } | ||
| 147 | time=$(sed -n -e "s/^\($stat\): \\(.*\\)/\\2/p" $file) | ||
| 148 | # in case the stat is not present, set the value as NA | ||
| 149 | [ -z "$time" ] && { time="NA"; } | ||
| 150 | # Append it to times | ||
| 151 | if [ -z "$times" ]; then | ||
| 152 | times="${time}" | ||
| 153 | else | ||
| 154 | times="${times} ${time}" | ||
| 155 | fi | ||
| 156 | done | ||
| 157 | if [ -n "$ACCUMULATE" ]; then | ||
| 158 | IFS=' '; valuesarray=(${times}); IFS=':' | ||
| 159 | times=0 | ||
| 160 | for value in "${valuesarray[@]}"; do | ||
| 161 | [ "$value" == "NA" ] && { echo "ERROR: stat is not present."; usage; exit 1; } | ||
| 162 | times=$(( $times + $value )) | ||
| 163 | done | ||
| 164 | fi | ||
| 165 | echo "${task} ${recipe} ${times}" | ||
| 166 | done | ||
| 167 | done | ||
