aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLisa Nguyen <lisa.nguyen@linaro.org>2015-10-21 17:57:04 -0700
committerLisa Nguyen <lisa.nguyen@linaro.org>2015-11-17 01:21:19 -0800
commit374c1b5bc8afccd4cd839d9fe9ab8ba69b43055e (patch)
tree31f4622d8594a124fe7102832294857f4b407a3e
parente66966ef6a08cd3b491ee1df5c6c5d33baaf1f1c (diff)
Replace bc commands
Some systems may not support the bc command. Replace with an alterative that performs simple floating- point arithmetic. Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
-rwxr-xr-xcpufreq/cpufreq_06.sh10
-rw-r--r--include/functions.sh8
2 files changed, 9 insertions, 9 deletions
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh
index 87b2c73..b86db34 100755
--- a/cpufreq/cpufreq_06.sh
+++ b/cpufreq/cpufreq_06.sh
@@ -42,7 +42,7 @@ compute_freq_ratio() {
return 1
fi
- value=$(echo "scale=3;($result / $freq)" | bc -l)
+ value=$(echo $result $freq | awk '{ printf "%.3f", $1 / $2 }')
eval $freq_results_array$index=$value
eval export $freq_results_array$index
index=$((index + 1))
@@ -53,7 +53,7 @@ compute_freq_ratio_sum() {
sum=0
res=$(eval echo \$$freq_results_array$index)
- sum=$(echo "($sum + $res)" | bc -l)
+ sum=$(echo $sum $res | awk '{ printf "%f", $1 + $2 }')
index=$((index + 1))
}
@@ -63,14 +63,14 @@ __check_freq_deviation() {
res=$(eval echo \$$freq_results_array$index)
# compute deviation
- dev=$(echo "scale=3;((( $res - $avg ) / $avg) * 100 )" | bc -l)
+ 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 > 5.0)" | bc -l)
+ res=$(echo $dev | awk '{printf "%f", ($dev > 5.0)}')
if [ "$res" = "1" ]; then
return 1
fi
@@ -97,7 +97,7 @@ check_deviation() {
for_each_frequency $cpu compute_freq_ratio_sum
- avg=$(echo "scale=3;($sum / $index)" | bc -l)
+ avg=$(echo $sum $index | awk '{ printf "%.3f", $1 / $2}')
for_each_frequency $cpu check_freq_deviation
}
diff --git a/include/functions.sh b/include/functions.sh
index 518f555..bb71302 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -188,16 +188,16 @@ wait_latency() {
frequnit() {
freq=$1
- ghz=$(echo "scale=1;($freq / 1000000)" | bc -l)
- mhz=$(echo "scale=1;($freq / 1000)" | bc -l)
+ ghz=$(echo $freq | awk '{printf "%.1f", ($1 / 1000000)}')
+ mhz=$(echo $freq | awk '{printf "%.1f", ($1 / 1000)}')
- ghz_value=$(echo "($ghz > 1.0)" | bc -l)
+ ghz_value=$(echo $ghz | awk '{printf "%f", ($1 > 1.0)}')
if [ "$ghz_value" = "1" ]; then
echo $ghz GHz
return 0
fi
- mhz_value=$(echo "($mhz > 1.0)" | bc -l)
+ mhz_value=$(echo $mhz | awk '{printf "%f", ($1 > 1.0)}')
if [ "$mhz_value" = "1" ];then
echo $mhz MHz
return 0