我想在几个不同的条件下在linux shell 中执行某些操作,并且能够输出每次执行的执行时间。
我知道我可以编写一个 perl 或 python 脚本来执行此操作,但是有没有办法在 shell 中执行此操作? (恰好是 bash)
使用内置的time
关键词:
$ 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.
Example:
$ time sleep 2
real 0m2.009s
user 0m0.000s
sys 0m0.004s
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)