我想要的是开始在我的代码中的某个地方计算时间,然后获得通过的时间,以测量执行少量功能所花费的时间.我认为我使用的是timeit模块错误,但文档对我来说只是让人困惑.
import timeit
start = timeit.timeit()
print("hello")
end = timeit.timeit()
print(end - start)
Run Code Online (Sandbox Code Playgroud) 我%%time在 Jupyter-notebook 中使用来测量我的 Python 代码的运行时间。问题是它只Wall time在Windows上打印,但在Ubuntu上运行良好。
是否也可以CPU time在Windows上获取?
我使用的是 Windows 10,Python 3.6 Anaconda 版本。