From 7b827d95adb0c8ae5dff1bdad7fd51ff50065dfe Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Mon, 4 Dec 2017 15:37:03 +0800 Subject: [PATCH] use awk command to replace bc --- benchmark/paddle/image/run_mkldnn_infer.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmark/paddle/image/run_mkldnn_infer.sh b/benchmark/paddle/image/run_mkldnn_infer.sh index 03a76c05400..d795bcab1b7 100755 --- a/benchmark/paddle/image/run_mkldnn_infer.sh +++ b/benchmark/paddle/image/run_mkldnn_infer.sh @@ -4,7 +4,7 @@ function clock_to_seconds() { hours=`echo $1 | awk -F ':' '{print $1}'` mins=`echo $1 | awk -F ':' '{print $2}'` secs=`echo $1 | awk -F ':' '{print $3}'` - echo `bc -l <<< "$secs + $mins * 60 + $hours * 3600"` + echo `awk 'BEGIN{printf "%.2f",('$secs' + '$mins' * 60 + '$hours' * 3600)}'` } function infer() { @@ -58,9 +58,9 @@ function infer() { end=`tail ${log} -n 2 | head -n 1 | awk -F ' ' '{print $2}' | xargs` start_sec=`clock_to_seconds $start` end_sec=`clock_to_seconds $end` - fps=`bc <<< "scale = 2; 1280 / ($end_sec - $start_sec)"` + fps=`awk 'BEGIN{printf "%.2f",(1280 / ('$end_sec' - '$start_sec'))}'` echo "Last 1280 samples start: ${start}(${start_sec} sec), end: ${end}(${end_sec} sec;" >> ${log} - echo "FPS: $fps images/sec" >> ${log} + echo "FPS: $fps images/sec" 2>&1 | tee -a ${log} } if [ ! -f "train.list" ]; then -- GitLab