Python3 - Using timeit to measure script execution time externally

£可爱£侵袭症+ 提交于 2019-12-11 16:52:52

问题


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?

来源:https://stackoverflow.com/questions/47877966/python3-using-timeit-to-measure-script-execution-time-externally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!