簡易ベンチマークスクリプト
全くたいしたものではありませんが、前にも似たようなのを書いて使ったのにロストして、また書いたのでウェブ上に晒しておきます。
#!/bin/sh # ex. benchmark.sh test1.sh test2.sh 1000 # ex. benchmark.sh test1.sh "" 1000 script_1=$1 script_2=$2 count=$3 if [ "${script_1}" = "" ]; then echo "benchmark.sh: usage: benchmark.sh script1 [script2 times]" exit 1 elif [ "${count}" = "" ]; then count=1 fi function benchmark { script=$1 start_time=`date +%H:%M:%S.%N | head -c11` i=0 while [ ${i} -le ${count} ]; do ${script} let i=${i}+1 done end_time=`date +%H:%M:%S.%N | head -c11` echo "Executed ${script} ${count} time(s) : ${start_time} -> ${end_time}" } benchmark ${script_1} [ "${script_2}" != "" ] && benchmark ${script_2} exit 0