summaryrefslogtreecommitdiffstats
path: root/scripts/contrib/bb-perf/buildstats.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/contrib/bb-perf/buildstats.sh')
-rwxr-xr-xscripts/contrib/bb-perf/buildstats.sh131
1 files changed, 66 insertions, 65 deletions
diff --git a/scripts/contrib/bb-perf/buildstats.sh b/scripts/contrib/bb-perf/buildstats.sh
index 2f017efeb8..e45cfc146d 100755
--- a/scripts/contrib/bb-perf/buildstats.sh
+++ b/scripts/contrib/bb-perf/buildstats.sh
@@ -66,62 +66,63 @@ EOM
66 66
67# Parse and validate arguments 67# Parse and validate arguments
68while getopts "b:r:t:s:aHh" OPT; do 68while getopts "b:r:t:s:aHh" OPT; do
69 case $OPT in 69 case $OPT in
70 b) 70 b)
71 BS_DIR="$OPTARG" 71 BS_DIR="$OPTARG"
72 ;; 72 ;;
73 r) 73 r)
74 RECIPE="$OPTARG" 74 RECIPE="$OPTARG"
75 ;; 75 ;;
76 t) 76 t)
77 TASKS="$OPTARG" 77 TASKS="$OPTARG"
78 ;; 78 ;;
79 s) 79 s)
80 STATS="$OPTARG" 80 STATS="$OPTARG"
81 ;; 81 ;;
82 a) 82 a)
83 ACCUMULATE="y" 83 ACCUMULATE="y"
84 ;; 84 ;;
85 H) 85 H)
86 HEADER="y" 86 HEADER="y"
87 ;; 87 ;;
88 h) 88 h)
89 usage 89 usage
90 exit 0 90 exit 0
91 ;; 91 ;;
92 *) 92 *)
93 usage 93 usage
94 exit 1 94 exit 1
95 ;; 95 ;;
96 esac 96 esac
97done 97done
98 98
99# Ensure the buildstats folder exists 99# Ensure the buildstats folder exists
100if [ ! -d "$BS_DIR" ]; then 100if [ ! -d "$BS_DIR" ]; then
101 echo "ERROR: $BS_DIR does not exist" 101 echo "ERROR: $BS_DIR does not exist"
102 usage 102 usage
103 exit 1 103 exit 1
104fi 104fi
105 105
106stats="" 106stats=""
107IFS=":" 107IFS=":"
108for stat in ${STATS}; do 108for stat in ${STATS}; do
109 case $stat in 109 case $stat in
110 TIME) 110 TIME)
111 stats="${stats}:${TIME}" 111 stats="${stats}:${TIME}"
112 ;; 112 ;;
113 IO) 113 IO)
114 stats="${stats}:${IO}" 114 stats="${stats}:${IO}"
115 ;; 115 ;;
116 RUSAGE) 116 RUSAGE)
117 stats="${stats}:${RUSAGE}" 117 stats="${stats}:${RUSAGE}"
118 ;; 118 ;;
119 CHILD_RUSAGE) 119 CHILD_RUSAGE)
120 stats="${stats}:${CHILD_RUSAGE}" 120 stats="${stats}:${CHILD_RUSAGE}"
121 ;; 121 ;;
122 *) 122 *)
123 stats="${STATS}" 123 stats="${STATS}"
124 esac 124 ;;
125 esac
125done 126done
126 127
127# remove possible colon at the beginning 128# remove possible colon at the beginning
@@ -140,27 +141,27 @@ for task in ${TASKS}; do
140 task="do_${task}" 141 task="do_${task}"
141 for file in $(find ${BS_DIR} -type f -path *${RECIPE}*/${task} | awk 'BEGIN{ ORS=""; OFS=":" } { print $0,"" }'); do 142 for file in $(find ${BS_DIR} -type f -path *${RECIPE}*/${task} | awk 'BEGIN{ ORS=""; OFS=":" } { print $0,"" }'); do
142 recipe="$(basename $(dirname $file))" 143 recipe="$(basename $(dirname $file))"
143 times="" 144 times=""
144 for stat in ${stats}; do 145 for stat in ${stats}; do
145 [ -z "$stat" ] && { echo "empty stats"; } 146 [ -z "$stat" ] && { echo "empty stats"; }
146 time=$(sed -n -e "s/^\($stat\): \\(.*\\)/\\2/p" $file) 147 time=$(sed -n -e "s/^\($stat\): \\(.*\\)/\\2/p" $file)
147 # in case the stat is not present, set the value as NA 148 # in case the stat is not present, set the value as NA
148 [ -z "$time" ] && { time="NA"; } 149 [ -z "$time" ] && { time="NA"; }
149 # Append it to times 150 # Append it to times
150 if [ -z "$times" ]; then 151 if [ -z "$times" ]; then
151 times="${time}" 152 times="${time}"
152 else 153 else
153 times="${times} ${time}" 154 times="${times} ${time}"
154 fi 155 fi
155 done
156 if [ -n "$ACCUMULATE" ]; then
157 IFS=' '; valuesarray=(${times}); IFS=':'
158 times=0
159 for value in "${valuesarray[@]}"; do
160 [ "$value" == "NA" ] && { echo "ERROR: stat is not present."; usage; exit 1; }
161 times=$(( $times + $value ))
162 done 156 done
163 fi 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
164 echo "${task} ${recipe} ${times}" 165 echo "${task} ${recipe} ${times}"
165 done 166 done
166done 167done