本文介绍了获取程序的执行时间在外壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想了几个不同的条件下执行在Linux Shell中的东西,并且能够输出每个执行的执行时间。
I want to execute something in a linux shell under a few different conditions, and be able to output the execution time of each execution.
我知道我可以写一个Perl或Python脚本,将做到这一点,但有一个方法可以让我做的壳呢? (这恰好是bash)的
I know I could write a perl or python script that would do this, but is there a way I can do it in the shell? (which happens to be bash)
推荐答案使用内建的时间命令:
$ help time time: time [-p] PIPELINE Execute PIPELINE and print a summary of the real time, user CPU time, and system CPU time spent executing PIPELINE when it terminates. The return status is the return status of PIPELINE. The `-p' option prints the timing summary in a slightly different format. This uses the value of the TIMEFORMAT variable as the output format. times: times Print the accumulated user and system times for processes run from the shell.例如:
$ time sleep 2 real 0m2.009s user 0m0.000s sys 0m0.004s更多推荐
获取程序的执行时间在外壳
发布评论