I have the following bash code (A.cpp, B.cpp and C.txt are filename in the current directory):
#!/bin/bash
g++ A.cpp -o A
g++ B.cpp -o B
Inputfiles=(X Y Z U V)
for j in "${Inputfiles[@]}"
do
echo $j.txt:
i=1
while [ $i -le 5 ]
do
./A $j.txt
./B C.txt
echo ""
i=`expr $i + 1`
done
echo ""
done
rm -f A B
One execution of ./A and ./B is one execution of my program. I run my program 5 times for each input file in the array 'Inputfiles'. I want the average execution time of my program over each input-file. How can I do so?
(Earlier, I tried to add time and clock functions within the A.cpp and B.cpp files, but I am not able to add the execution times of both files to get the execution time of a program.)