diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-24 23:04:45 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-24 23:04:45 +0900 |
| commit | 787dc13c837f0955fbd85b8f26a05d720d361333 (patch) | |
| tree | fec3abebb1e867e8b2239d7cf07b4c7d13ce0f81 /comparison/tools/sptest_commands.sh | |
| parent | e607a57dfafb784c4e27da143214afb2ccd07fbf (diff) | |
| download | inpla-787dc13c837f0955fbd85b8f26a05d720d361333.tar.gz inpla-787dc13c837f0955fbd85b8f26a05d720d361333.zip | |
Upload the comparison directory
Diffstat (limited to 'comparison/tools/sptest_commands.sh')
| -rw-r--r-- | comparison/tools/sptest_commands.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/comparison/tools/sptest_commands.sh b/comparison/tools/sptest_commands.sh new file mode 100644 index 0000000..d608d2c --- /dev/null +++ b/comparison/tools/sptest_commands.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# $1: name list of commands +# ex: ./sptest_commands.sh fib38 bsort-40000 + + +# repeat and waittimes +ct=10 +waittime=5 + +# etc +log="log.txt" + +# ------------------------------------------------- +function mywait() { + for w in $(seq 1 $waittime) ; do + echo -n "." + sleep 1 + done +} + +function gettime() { + rm -f _result.txt + for i in $(seq 1 $ct) ; do + (time $1) 2>> _result.txt + echo + echo "Done ($i/$ct)" + if [[ $(($i + 1)) -le $ct ]]; then + mywait + echo 'Restart' + fi + done + echo + echo + logtime=`grep real _result.txt | cut -f2 | sed -e "s/\(.*\)m\(.*\)s/\1 \2/" | awk -F' ' '{print ($1*60+$2)}'` + echo "execution time" + echo "$logtime" + + # for return value + res=`echo $logtime | awk 'BEGIN{r=0;c=0} {r=r+$0;c++} END{print r/c}'` + rm -f _result.txt +} + + +rm -f $log + +echo '' >> $log +echo "$ct" | awk -F',' '{printf("%-27s| avg. time over %d runs (sec)\n","",$1)}' >> $log +echo '===========================+=============================' >> $log + +for f in "$@"; do + command="$f" + echo -n "Cooling CPU in $waittime sec" + mywait + echo ' The experiment starts.' + echo "------------------" + echo "$f" + gettime "./$f" + echo "Average ${res}sec" + echo "$command,$res" | awk -F',' '{printf("%-27s| %.2f\n",$1,$2)}' >> $log +done + +echo +cat $log + |
