您的位置:首页 > 运维架构 > Linux

Linux命令之time - 测定一个命令的运行时间!

2012-07-04 17:07 615 查看
time命令常用于测量一个命令的运行时间,注意不是用来显示和修改系统时间的(这是date命令干的事情)。包括实际使用时间(realtime)、用户态使用时间(the process spent in user mode)、内核态使用时间(the process spent in kernel mode)。

常用参数
time命令最常用的使用方式就是在其后面直接跟上命令和参数:
time <command> [<arguments...>]
在命令执行完成之后就会打印出CPU的使用情况:
real 0m5.064s <== 实际使用时间(real time)

user 0m0.020s <== 用户态使用时间(the process spent in user mode)

sys 0m0.040s <==
内核态使用时间(the process spent in kernel mode)

time命令跟上-p参数可以只打印时间数值(秒数),不打印单位。

使用示例
[root@linux ~]# time -p date
2012年 07月 05日 星期四 00:32:51 CST
real 0.01
user 0.00
sys 0.01
[root@linux ~]# time date
2012年 07月 05日 星期四 00:33:00 CST

real    0m0.010s
user    0m0.001s
sys     0m0.008s
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: