1. 程式人生 > >Linux之time命令

Linux之time命令

-s 缺省 ota command ... 16px comm tftp blog

Linux中的time命令常常用來計算某個程序的運行耗時(real),用戶態cpu耗時(user),系統態cpu耗時(sys)。

格式:time [-p] command [arguments...]

time命令最常用的使用方式就是在其後直接跟上命令和參數,例如:

1 [email protected]:/home/share$ time ls -l
2 total 8
3 drwxrwxrwx 2 root root 4096 Jul  3 00:53 nfs
4 drwxrwxrwx 2 root root 4096 Jul  3 00:03 tftp
5 
6 real    0m0.072s
7 user 0m0.000s 8 sys 0m0.000s

real表示程序運行耗時時間

user表示程序運行在用戶態的耗時時間

sys表示程序運行在內核態的耗時時間

參數說明:

-p表示缺省時間單位,只打印時間數值,單位為妙。例如:

1 [email protected]:/home/share$ time -p ls -l
2 total 8
3 drwxrwxrwx 2 root root 4096 Jul  3 00:53 nfs
4 drwxrwxrwx 2 root root 4096 Jul  3 00:03 tftp
5 real 0.08
6 user 0.00
7 sys 0.00

Linux之time命令