如何在终端显示运行时间?(How to show running time in terminal?)

编程入门 行业动态 更新时间:2024-10-27 16:27:52
如何在终端显示运行时间?(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.

更多推荐

本文发布于:2023-08-06 15:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1451333.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:终端   时间   如何在   show   time

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!