Declare total=O
for repeat in {1..100}; do
executiontime=$(gtime -f "%U" python3 main.py | tail -0)
total=$(echo "scale=2; $total + $executiontime" | bc)
done
echo "$total/100"
The code above is a part of a loop, and I need the variable total
to be able to have the average of execution time of the file main.py. I am having a hard time getting to print the value of the variable total
since it is a floating point variable. What is the correct syntax to do this?
This is the output I am getting:
(standard_in) 2: parse error
I think the issue is within the command tail when I use :
gtime -f "%U" python3 main.py | tail -1
this is the output I get:
$ ./gtime -f "%U" python3 main.py | tail -1
10.08
)
but then with tail -0
gtime -f "%U" python3 main.py | tail -0
9.66