~pwlars/ubuntu-test-cases/krillin-recovery

« back to all changes in this revision

Viewing changes to tests/systemsettle/systemsettle.sh

  • Committer: Paul Larson
  • Date: 2014-10-21 15:40:57 UTC
  • Revision ID: paul.larson@canonical.com-20141021154057-zk465lswaexddae7
Find a better default location for the wifi configuration

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
   echo " -m  maximum loops of top before giving up if minimum idle"
27
27
   echo "     percent is not reached (Default: 10)"
28
28
   echo " -l  label to include for the top_log file"
 
29
   echo " -s  sleep timeout for %cpu calculation (Default: 10)"
29
30
   exit 129
30
31
}
31
32
 
32
 
while getopts "h?rp:c:d:i:m:l:" opt; do
 
33
while getopts "h?rp:c:d:i:m:l:s:" opt; do
33
34
    case "$opt" in
34
35
        h|\?) show_usage
35
36
              ;;
47
48
              ;;
48
49
        l)    top_log_label=$OPTARG
49
50
              ;;
 
51
        s)    sleep_len=$OPTARG
 
52
              ;;
50
53
    esac
51
54
done
52
55
 
 
56
sleep_len=${sleep_len:-10}
 
57
HZ=`getconf CLK_TCK`
53
58
# minimum average idle level required to succeed
54
59
idle_avg_min=${idle_avg_min:-99}
55
60
# measurement details: top $top_wait $top_repeat
85
90
  # get top
86
91
  echo "TOP DUMP (after settle run: $settle_count)" >> $top_log
87
92
  echo "========================" >> $top_log
88
 
  ${TARGET_PREFIX} top -b -d $top_wait -n $top_repeat >> $top_log
 
93
  ${TARGET_PREFIX} COLUMNS=900 top -c -b -d $top_wait -n $top_repeat >> $top_log
89
94
  cat $top_log | grep '.Cpu.*' | tail -n $top_tail > $top_log.reduced
90
95
  echo >> $top_log
91
96
 
92
 
  # calc average of idle field for this measurement
93
 
  sum=0
94
 
  count=0
95
 
  while read line; do
96
 
     idle=`echo $line | sed -e 's/.* \([0-9\.]*\) id.*/\1/'`
97
 
     sum=`calc $sum + $idle`
98
 
     count=`calc $count + 1`
99
 
  done < $top_log.reduced
100
 
 
101
 
  idle_avg=`calc $sum / $count`
 
97
  # Instead of using top, we need to use /proc/stat and compensate for
 
98
  # the number of cpus and any frequency scaling that could be in effect
 
99
  cpu_avg=$({
 
100
    ${TARGET_PREFIX} cat /proc/stat
 
101
    sleep "$sleep_len"
 
102
    ${TARGET_PREFIX} cat /proc/stat
 
103
  } | awk '
 
104
    BEGIN       { iter = 0 }
 
105
    /^cpu /     { iter = iter + 1; count = 0; next }
 
106
    /^cpu/      { S[iter] = S[iter] + ($2+$3+$4+$6); count = count + 1;
 
107
next }
 
108
    END     { print (S[2] - S[1]) * 100 / ('"$HZ"' * count * '"$sleep_len"') }
 
109
  ')
 
110
  idle_avg=`calc 100 - $cpu_avg`
102
111
  settle_count=`calc $settle_count + 1`
103
112
 
104
113
  echo " DONE."
105
114
  echo
106
115
  echo "Measurement:"
107
116
  echo "  + idle level: $idle_avg"
108
 
  echo "  + idle sum: $sum / count: $count"
109
117
  echo
110
118
done
111
119