如果您在 Ubuntu 18.04 中测量时间,结果会显示在一行中:
$ time sleep 1
sleep 1 0.00s user 0.00s system 0% cpu 1.003 total
Run Code Online (Sandbox Code Playgroud)
这不符合 POSIX 标准,如time
的手册页中所述:
-p, --portability
Use the following format string, for conformance with POSIX standard 1003.2:
real %e
user %U
sys %S
Run Code Online (Sandbox Code Playgroud)
现在我的问题是:
为什么 Ubuntu 使用自己的格式来显示资源使用情况?
另外,我如何改变行为?使用-p
我上面引用的手册中的选项,我只会收到以下错误:
$ time -p sleep 1
zsh: command not found: -p
-p sleep 1 0.00s user 0.00s system 73% cpu 0.002 total
Run Code Online (Sandbox Code Playgroud)