码迷,mamicode.com
首页 > 系统相关 > 详细

Linux学习记录(三):time 相关

时间:2015-10-27 19:18:44      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:

time 不仅仅可以统计时间,还可以反映CPU、内存情况等。

一、time

格式  : time [options] [commands] [arguments]

time ls
 

real    0m0.016s   <== 实际使用时间(real time)

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

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

 

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

如 

time –p ls

real 0.01
user 0.00
sys 0.00

二、更为强大的外部命令     /usr/bin/time

其实:

[root@v01 ~]# type -a time
time is a shell keyword
time is /usr/bin/time

time 是/usr/bin/time 一个简单执行

/usr/bin/time 用法

[root@v01 ~]# /usr/bin/time
Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
       [--portability] [--format=format] [--output=file] [--version]
       [--help] command [arg...]

/usr/bin/time ls

0.00user 0.00system 0:00.01elapsed 10%CPU (0avgtext+0avgdata 4080maxresident)k
0inputs+0outputs (0major+294minor)pagefaults 0swaps

很强大有没有啊,再来一发

/usr/bin/time –v  ls

Command being timed: "ls"
        User time (seconds): 0.00
        System time (seconds): 0.00
        Percent of CPU this job got: 10%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.01
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 4096
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 298
        Voluntary context switches: 1
        Involuntary context switches: 8
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

重定向到文件   注意格式

{ time command-line; } 2>file

( time command-line ) 2>file

Linux学习记录(三):time 相关

标签:

原文地址:http://www.cnblogs.com/xinqi/p/4914965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!