In Java program, I usually use the following functions to profile time info:
...
long start = System.currentTimeMillis();
...
...
System.out.println("elapsed time 1: "+(System.currentTimeMills() - start));
...
...
start = System.currentTimeMillis();
...
System.out.println("elapsed time 2: "+(System.currentTimeMills() - start));
...
How to do similar things in shell bash? Further, how to collect the accumulated time if there is a loop?
e.g.
for ((i=0;i<$lines;i=i+$step))
do
head -$((i+step)) $1 | tail -$step > tmp1
head -$((i+step)) $2 | tail -$step > tmp2
setstr=$setstr' '`./accuracy.sh tmp1 tmp2`
done
echo $setstr | awk '{for (i=1;i<=NF;i++) sum+=$i; }END{print sum/NF}'
I want to profile the accumulated head/tail
time and accuracy.sh tmp1 tmp2
time separately.