Let's say I have a python script script.py
and I want to measure the execution time of it just as if I put the whole script in quotation marks and used:
from timeit import Timer
t = Timer(stmt='THE WHOLE SCRIPT')
print(t.timeit())
I could do this by editing script.py
, but I'd like not to. What I want is a second script measure.py
, which can be executed like ./measure.py script.py
, which will basically do the above with any script as an argument.
How could I approach writing such a script measure.py
?