我想使用 gnu time 来测量一些小 .c 程序的运行时间。 《人》中写道:
-f FORMAT, --format FORMAT
Use FORMAT as the format string that controls the output of time. See the below more information.
然后在示例中我们有:
To run the command `ls -Fs' and show just the user, system, and total time:
time -f "%E real,%U user,%S sys" ls -Fs
但是当我尝试从示例中发出此命令时,我得到:
time -f '%E real,%U user,%S sys' ls -Fs
-f: command not found
real 0m0.134s
user 0m0.084s
sys 0m0.044s
我想知道问题出在哪里,我哪里出错了?我只是想显示用户时间,这就是我玩弄时间输出格式的原因。
Bash 有一个内置的 shell 名为time
。绕过它的一种方法是输入command time
- 命令将忽略内置命令并运行time
程序从你的$PATH
。另一种方法是alias time=/usr/bin/time
。另一方面,bash 内置函数尊重环境变量TIMEFORMAT
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)