0

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.

0

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

1 Comment

I will try this code just wondering.is there way i can store execution time value in a variable?
0

Call the python script with /usr/bin/time script. This allows you to track CPU and wall-clock time of the script.

2 Comments

This will give the time to execute the bash script, not python script.
Yes correct it will tell us time taken by shell script not by the python script which is getting called inside.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.