如何在终端显示运行时间?(How to show running time in terminal?)
我正在使用Python一段时间,我通过某些方法(如timeit())了解到我可以估计我的程序的运行时间。
但是,当我的程序在终端完成时,它是否打印出运行时间? (任何终端命令都这样做?!)
I am using Python for a while and I learned that by some method like timeit() I can estimate the running time of my programe.
But, is it any way that when my programe finished in the terminal, it also print out the running time?! (any terminal command do that?!)
最满意答案
使用以下内容:
$ time your_programm
输出是:
$ time sleep 1
真正的0m1.002s
用户0m0.000s
sys 0m0.000s
显示在内核和用户空间中花费了多少时间以及花费的总时间。
Use the following:
$ time your_programm
the output is:
$ time sleep 1
real 0m1.002s
user 0m0.000s
sys 0m0.000s
showing how much time was spent in kernel and user space and the total time spent.
更多推荐
发布评论