gpt4 book ai didi

linux - 更准确地显示shell命令的执行时间

转载 作者:太空宇宙 更新时间:2023-11-04 09:02:54 24 4
gpt4 key购买 nike

以下将显示给定命令执行所花费的时间。我如何做同样的事情但精度更高(即 5.23 秒)?

[root@localhost ~]# start=`date +%s`; sleep 5  && echo execution time is $(expr `date +%s` - $start) seconds
execution time is 5 seconds
[root@localhost ~]#

最佳答案

您可以尝试使用时间命令。

time sleep 5

除了经过的挂钟时间之外,它还会告诉您进程消耗了多少 CPU 时间,以及有多少 CPU 时间花在了应用程序上,还有多少花在了操作系统调用上。

关于linux - 更准确地显示shell命令的执行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17390672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com