问题是,当我在shell中使用时间时,我得到如下输出:
1.350u 0.038s 0:01.45 95.1% 0+0k 0+72io 1pf+0w
Run Code Online (Sandbox Code Playgroud)
当我在脚本中使用它时,我得到:
real 0m1.253s
user 0m1.143s
sys 0m0.047s
Run Code Online (Sandbox Code Playgroud)
我的意思是为什么 在开头的shell脚本中我写道:
#!/bin/bash
Run Code Online (Sandbox Code Playgroud)
Bash有一个内置命令time,你的系统也应该有一个单独的二进制文件/usr/bin/time:
$ help time
time: time [-p] pipeline
Report time consumed by pipeline's execution.
Execute PIPELINE and print a summary of the real time, user CPU time,
...
$ which time
/usr/bin/time
这两个命令产生不同的输出:
$ time echo hi hi real 0m0.000s user 0m0.000s sys 0m0.000s $ /usr/bin/time echo hi hi 0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+199minor)pagefaults 0swaps