Yesterday, I was trying to get the running time of a program. time gives you only limited precision (second level (with 2 decimal digits))
So, i wrote up this script to do find the running time in bash:
#Find the runtime of program wget
for i in {1..100} ;
do
s=`date +A%S*1000000000+A%N`;
start=$((`echo $s | sed 's/A0*//g'`));
#Have to do this hack as every number that starts with a zero is considered as octal by bash.
wget -q http://site.com -Y on;
e=`date +A%S*1000000000+A%N`;
end=$((`echo $e | sed 's/A0*//g'`));
echo $(($end-$start));
done
No Comments on "Bash goodness"