【发布时间】:2012-08-19 06:48:54
【问题描述】:
在 UNIX/LINUX 中,是否有一种简单的方法来跟踪命令所用的时间?
【问题讨论】:
标签: linux unix command-line terminal
在 UNIX/LINUX 中,是否有一种简单的方法来跟踪命令所用的时间?
【问题讨论】:
标签: linux unix command-line terminal
使用
/usr/bin/time
而不是 bash 中内置的时间:它是更可配置的 AFAIK。
e.g. /usr/bin/time --format=' \n---- \nelapsed time is %e'ls
【讨论】:
user@host:~$ which time /usr/bin/time 看起来是 GNU 时间的 1.7 版。
time -f "\t%E real" ls,我会收到错误消息,但如果我执行 /usr/bin/time -f "\t%E real" ls,它会起作用。
which。使用type -a:$ which time /usr/bin/time $ type -a time time is a shell keyword time is /usr/bin/time
/usr/bin/time 会阻止您使用 bash 别名。为此需要 bash 内置 time,否则您将收到错误 cannot run my_alias: No such file or directory。
这是一秒钟的sleep 的样子,与time 计时:
$ time sleep 1
real 0m1.001s
user 0m0.000s
sys 0m0.000s
【讨论】: