在类 Unix 系统中,你可能知道一个命令或进程开始执行的时间,以及一个进程运行了多久。 但是,你如何知道这个命令或进程何时结束或者它完成运行所花费的总时长呢? 在类 Unix 系统中,这是非常容易的! 有一个专门为此设计的程序名叫 GNU time。 使用 time 程序,我们可以轻松地测量 Linux 操作系统中命令或程序的总执行时间。 time 命令在大多数 Linux 发行版中都有预装,所以你不必去安装它。
在 Linux 中查找一个命令或进程的执行时间
要测量一个命令或程序的执行时间,运行:
$ /usr/bin/time -p ls
或者,
$ time ls
输出样例:
dir1 dir2 file1 file2 mcelogreal 0m0.007suser 0m0.001ssys 0m0.004s$ time ls -a. .bash_logout dir1 file2 mcelog .sudo_as_admin_successful.. .bashrc dir2 .gnupg .profile .wget-hsts.bash_history .cache file1 .local .stackreal 0m0.008suser 0m0.001ssys 0m0.005s
评论列表()