我想使用 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 有一个名为 time
的内置 shell。克服它的一种方法是键入 command time
- 命令将忽略内置函数并从 $PATH
运行 time
程序。另一种方法是 alias time=/usr/bin/time
。另一方面,bash 内置命令遵守环境变量 TIMEFORMAT
。
关于linux - Gnu 时间和格式化输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9715570/