奋起直追,fighting
我在这里!

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

posted on 2015-10-27 17:30  Thomas_C  阅读(261)  评论(0编辑  收藏  举报