Changes in cpufreq_06.sh to calculate summatory and average of frequency measurements.
In the function 'compute_freq_ratio' the frequency is stored in an array of variables by indirect reference (http://www.tldp.org/LDP/abs/html/ivr.html) but the variable 'index' that points to next element in the array is initialized to 0 every time hence overriding the values. The same happens for the function 'compute_freq_ratio_sum' where the index variable is always initialized to 0 and the variable 'sum' is always set to 0 not adding the subsequent values. Hence this initializations must be deleted from those functions and written into the 'function check_deviation' for keeping the correct values and calculations of average. With these changes the tests now produce the correct results and the tests passes.
Signed-off-by: Saul Romero saul.romero@arm.com --- cpufreq/cpufreq_06.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh index b323dc8..a25bbd2 100755 --- a/cpufreq/cpufreq_06.sh +++ b/cpufreq/cpufreq_06.sh @@ -31,7 +31,7 @@ CPUCYCLE=../utils/cpucycle freq_results_array="results"
compute_freq_ratio() { - index=0 + #index=0 cpu=$1 freq=$2
@@ -49,25 +49,21 @@ compute_freq_ratio() { }
compute_freq_ratio_sum() { - index=0 - sum=0 + #index=0 + #sum=0
res=$(eval echo $$freq_results_array$index) sum=$(echo $sum $res | awk '{ printf "%f", $1 + $2 }') index=$((index + 1)) - }
__check_freq_deviation() { res=$(eval echo $$freq_results_array$index) - if [ ! -z "$res" ]; then # compute deviation dev=$(echo $res $avg | awk '{printf "%.3f", (($1 - $2) / $2) * 100}') - # change to absolute dev=$(echo $dev | awk '{ print ($1 >= 0) ? $1 : 0 - $1}') - index=$((index + 1)) res=$(echo $dev | awk '{printf "%f", ($dev > 5.0)}')
@@ -85,23 +81,20 @@ check_freq_deviation() {
cpu=$1 freq=$2 - check "deviation for frequency $(frequnit $freq)" __check_freq_deviation - }
check_deviation() {
cpu=$1 - set_governor $cpu userspace - + index=0 for_each_frequency $cpu compute_freq_ratio - + index=0;sum=0 for_each_frequency $cpu compute_freq_ratio_sum
avg=$(echo $sum $index | awk '{ printf "%.3f", $1 / $2}') - + index=0 for_each_frequency $cpu check_freq_deviation }
-- 2.5.0
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.