I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script. Any leads would be helpful thanks in advance.
Asked
Active
Viewed 1,171 times
2 Answers
0
You can use the time
command to get the runtime of the python script.
]$ cat time_test.bash
#!/bin/bash
# You can use: time python script.py
time python -c 'import os;os.getenv("HOME")'
Output will be something like this
]$ ./time_test.bash
real 0m0.010s
user 0m0.005s
sys 0m0.005s

iamauser
- 11,119
- 5
- 34
- 52
-
I will try this code just wondering.is there way i can store execution time value in a variable? – MrAdfire Apr 15 '17 at 02:30
0
Call the python script with /usr/bin/time script
. This allows you to track CPU and wall-clock time of the script.

W.Mann
- 893
- 5
- 11
-
This will give the time to execute the bash script, not python script. – iamauser Apr 14 '17 at 17:57
-
Yes correct it will tell us time taken by shell script not by the python script which is getting called inside. – MrAdfire Apr 14 '17 at 17:59