time命令小结

When the -p option is given the (portable) output format

real %e

user %U

sys %S

time - time a simple command or give resource usage   #一个简单的命令或提供资源使用

[[email protected] ~]# time

real    0m0.000s

user    0m0.000s

sys     0m0.000s

%e     (Not in tcsh.) Elapsed real time (in seconds).   #(不是在tcsh。)真正的时间(以秒为单位)。

%S     Total number of CPU-seconds that the process spent in kernel mode.  #CPU在内核模式的过程中秒总数。

%U     Total number of CPU-seconds that the process spent in user mode.    #CPU在用户模式的过程中秒总数。

1)实际时间(real time): 从command命令行开始执行到运行终止的消逝时间;

2)用户CPU时间(user CPU time): 命令执行完成花费的用户CPU时间,即命令在用户态中执行时间总和;

3)系统CPU时间(system CPU time): 命令执行完成花费的系统CPU时间,即命令在核心态中执行时间总和。

其中,用户CPU时间和系统CPU时间之和为CPU时间,即命令占用CPU执行的时间总和。实际时间要大于CPU时间,因为Linux是多任务操作系统,往往在执行一条命令时,系统还要处理其它任务。

使用-p 参数后的时间显示格式为NN.FF,其单位为秒。

[[email protected] ~]# time -p find . -name "mysql.sh"

real 0.00

user 0.00

sys 0.00

[[email protected] ~]# man time

TIME(1)                                                                TIME(1)

NAME

time - time a simple command or give resource usage

SYNOPSIS

time [options] command [arguments...]

DESCRIPTION

The  time  command  runs  the  specified  program command with the given arguments.  When command finishes, time

writes a message to standard error giving timing statistics about this program run.  These statistics consist of

(i)  the  elapsed real time between invocation and termination, (ii) the user CPU time (the sum of the tms_utime

and tms_cutime values in a struct tms as returned by times(2)), and (iii) the system CPU time (the  sum  of  the

tms_stime and tms_cstime values in a struct tms as returned by times(2)).

Note: some shells (e.g., bash(1)) have a built-in time command that provides less functionality than the command

described  here.   To  access  the  real  command,  you  may  need  to  specify  its  pathname  (something  like

/usr/bin/time).

OPTION

-p     When in the POSIX locale, use the precise traditional format

"real %f\nuser %f\nsys %f\n"

(with  numbers in seconds) where the number of decimals in the output for %f is unspecified but is suffi-

cient to express the clock tick accuracy, and at least one.

ENVIRONMENT

The variables LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, NLSPATH and PATH are used. The last one to search

for command.  The remaining ones for the text and formatting of the output.

EXIT STATUS

If  command was invoked, the exit status is that of command.  Otherwise it is 127 if command could not be found,

126 if it could be found but could not be invoked, and some other non-zero value (1-125) if something else  went

wrong.

SEE ALSO

times(2)

GNU VERSION

Below  a  description of the GNU 1.7 version of time.  Disregarding the name of the utility, GNU makes it output

lots of useful information, not only about time used, but also on other resources like memory, I/O and IPC calls

(where  available).   The output is formatted using a format string that can be specified using the -f option or

the TIME environment variable.

The default format string is

%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k

%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps

When the -p option is given the (portable) output format

real %e

user %U

sys %S

is used.

The format string

The format is interpreted in the usual printf-like way.  Ordinary characters are directly copied,  tab,  newline

and  backslash are escaped using \t, \n and \\, a percent sign is represented by %%, and otherwise % indicates a

conversion. The program time will always add a trailing newline itself.  The conversions follow.  All  of  those

used by tcsh(1) are supported.

Time

%E     Elapsed real time (in [hours:]minutes:seconds).    #真正的时间((小时:分钟:秒)。

%e     (Not in tcsh.) Elapsed real time (in seconds).  #(不是在tcsh。)真正的时间(以秒为单位)。

%S     Total number of CPU-seconds that the process spent in kernel mode.  #CPU在内核模式的过程中秒总数。

%U     Total number of CPU-seconds that the process spent in user mode.   #CPU在用户模式的过程中秒总数。                                                                                 Sat May 31 22:24:40 2014

%P     Percentage of the CPU that this job got, computed as (%U + %S) / %E.  #比例的CPU,这份工作,计算(% U + % S)/ % E。

Memory

%M     Maximum resident set size of the process during its lifetime, in Kbytes.   #在运行周期内最大驻留集的进程,单位是kb。

%t     (Not in tcsh.) Average resident set size of the process, in Kbytes.  #(不是在tcsh。)平均驻留集大小在进程中,单位是kb。

%K     Average total (data+stack+text) memory use of the process, in Kbytes.   #平均总(数据+栈+文本)进程的内存使用,在kb。

%D     Average size of the process‘s unshared data area, in Kbytes.   #进程的平均尺寸的非共享数据区

%p     (Not in tcsh.) Average size of the process‘s unshared stack space, in Kbytes.  #(不是在tcsh。)过程的平均尺寸的非共享栈空间,在kb。

%X     Average size of the process‘s shared text space, in Kbytes.  #进程的共享文本空间的平均大小,kb。

%Z     (Not  in tcsh.) System‘s page size, in bytes.  This is a per-system constant, but varies between systems.

#(不是在tcsh。)系统的页面大小,以字节为单位。这是一个系统级别的常数,但不同系统之间。

%F     Number of major page faults that occurred while the process was running.  These are faults where the page

has to be read in from disk.

#一些主要的页面错误,在进程执行过程中发生。这些都是错误的页面必须从磁盘读取。

%R     Number  of  minor,  or recoverable, page faults.  These are faults for pages that are not valid but which

have not yet been claimed by other virtual pages.  Thus the data in the page is still valid but the  sys-

tem tables must be updated.

#小的数量,或可恢复,页面错误。这些错误的页面是无效的,但还没有被其他虚拟页面声称。因此页面中的数据仍然有效,但必须更新系统表。

%W     Number of times the process was swapped out of main memory.

#次数时间的进程被换出内存。

%c     Number of times the process was context-switched involuntarily (because the time slice expired).

#进程上下文切换的次数不自觉地(因为时间片过期)。

%w     Number  of waits: times that the program was context-switched voluntarily, for instance while waiting for

an I/O operation to complete.

#:等待的次数,该项目被自愿交换上下文,例如在等待I / O操作完成。

I/O

%I     Number of file system inputs by the process.   #一些文件系统输入的过程。

%O     Number of file system outputs by the process.   #一些文件系统输出的过程。

%r     Number of socket messages received by the process.  #套接字接收到的消息的过程。

%s     Number of socket messages sent by the process.    #套接字发送的消息数量的过程。

%k     Number of signals delivered to the process.     #数量的信号传递过程。

%C     (Not in tcsh.) Name and command line arguments of the command being timed.

#(不是在tcsh。)名称和命令的命令行参数被计时。

%x     (Not in tcsh.) Exit status of the command.

#(不是在tcsh。)命令的退出状态。

GNU OPTIONS

-f FORMAT, --format=FORMAT

Specify output format, possibly overriding the format specified in the environment variable TIME.

-p, --portability

Use the portable output format.

-o FILE, --output=FILE

Do not send the results to stderr, but overwrite the specified file.

-a, --append

(Used together with -o.) Do not overwrite but append.

-v, --verbose

Give very verbose output about all the program knows about.

GNU STANDARD OPTIONS

--help Print a usage message on standard output and exit successfully.

-V, --version

Print version information on standard output, then exit successfully.

--     Terminate option list.

BUGS

Not all resources are measured by all versions of Unix, so some of the values might be reported  as  zero.   The

present selection was mostly inspired by the data provided by 4.2 or 4.3BSD.

GNU time version 1.7 is not yet localized.  Thus, it does not implement the POSIX requirements.

The  environment  variable  TIME  was  badly chosen.  It is not unusual for systems like autoconf or make to use

environment variables with the name of a utility to override the utility to be used. Uses like MORE or TIME  for

options to programs (instead of program pathnames) tend to lead to difficulties.

It seems unfortunate that -o overwrites instead of appends.  (That is, the -a option should be the default.)

Mail suggestions and bug reports for GNU time to

[email protected]

Please include the version of time, which you can get by running

time --version

and the operating system and C compiler you used.

SEE ALSO

tcsh(1), times(2), wait3(2)

AUTHORS

David Keppel

Original version

David MacKenzie

POSIXization,  autoconfiscation,  GNU  getoptization,  documentation, other bug fixes and improve-

ments.

Arne Henrik Juul

Helped with portability

Francois Pinard

Helped with portability

2000-12-11                           TIME(1)

时间: 2024-10-07 22:20:18

time命令小结的相关文章

Lniux常见的压缩/解压命令小结

转载请注明: 导航制导与控制实验室 2014年12月16日 在linux开发过程中,经常会遇资料的打包/解包.压缩/解压:本文我将在linux系统中常用的命令进行了整理和分类,内容如下: 1.tar 命令,主要是对Dir先归档,在借助其他命令处理归档文件: 2.单个文件的压缩命令,对单个文件进行处理的命令,有时也可以借助tar命令对目录先打包,再进行压缩: 3.zip.rar压缩命令,即可对单个文件也可对目录进行压缩处理,该方法利于不同操作系统的处理: 该文章只是作者本人的理解,有些命令还会验证

Cisco路由器auto secure命令小结

路由器命令auto secure用起来比较方便,而且可以关闭一些不安全的服务和启用一些安全的服务.这里对这个命令做了一个总结.(注:ios版本为:12.3(1)以上才支持使用) 总结如下:     1.关闭一些全局的不安全服务如下: Finger PAD Small Servers Bootp HTTP service Identification Service CDP NTP Source Routing 2.开启一些全局的安全服务如下: PassWord-encryption servic

Linux sed命令小结

1.什么是sed sed,流编辑器,即stream editor.它可以将文本文件的每一行读取到内存,即所谓sed的模式空间,在这个模式空间中可以进行编辑并输出. 2.sed的使用格式 sed [options] "AdressCommand" file1,file2,... 说明: a.Adress实际上是用来确定编辑文件的范围,可以是精确的某一行,也可以是从某一行到某一行,也   可以用正则进行过滤匹配. b.Command表示将符合Address的行进行XXX操作.注意默认情况下

Linux后台进程管理的一些命令小结

Linux后台进程管理的一些命令:fg.bg.jobs.&.ctrl + z命令,供大家学习参考 一. &加在一个命令的最后,可以把这个命令放到后台执行 ,如gftp &, 二.ctrl + z可以将一个正在前台执行的命令放到后台,并且处于暂停状态,不可执行 三.jobs查看当前有多少在后台运行的命令jobs -l选项可显示所有任务的PID,jobs的状态可以是running, stopped, Terminated,但是如果任务被终止了(kill),shell 从当前的shell

Oracle 常用命令小结

1.当前数据库中查看建表语句 select dbms_metadata.get_ddl('TABLE','表名') from dual; 2. Oracle 常用命令小结,布布扣,bubuko.com

Linux常用命令小结(续)

20. mysql mysql --host=127.0.0.1 --port=3306 --database=test --user=test --password=test --default-character-set=utf8 21. 脚本求两个文件的相同集合 test1   test2 1           2 2           3 3           4 cat test1 test2 | sort | uniq -d (result: 2 3) cat test1 te

MySQL 数据库常用命令小结

1.MySQL常用命令 create database name; 创建数据库 use databasename; 选择数据库 drop database name 直接删除数据库,不提醒 show tables; 显示表 describe tablename; 表的详细描述 select 中加上distinct去除重复字段 mysqladmin drop databasename 删除数据库前,有提示. 显示当前mysql版本和当前日期 select version(),current_dat

find命令小结

find命令小结 find命令用于在系统中查找文件,配合 -exec 选项或 xargs命令还能对查找到得文件执行一些列的自动化操作. 基本格式:find [-H] [-L] [-P] [path...] [expression] path指定起始搜索路径,可以指定多个,exprssion表示搜索表达式,包含选项及选项参数. [TOC] 表达式 -depth n (mac os): 指定只遍历深度为 n 的目录(相对起始目录),例如 1 表示只在当前目录搜索,2 表示只在当前目录的子目录中搜索,

[Shell&Mac&Environment variables]自己常用的Mac(或者说Linux)Shell命令小结,含Mac使用zsh shell的环境变量的有关配置方法

今天在使用tomcat的配置的时候,我用的mac,要是用到一些命令去配置tomcat. 问题来了: 我每次要去启动tomcat服务特别麻烦,因为我要先进入tomcat所在的文件目录,或者不进入使用~/,但是因为我把tomcat放到了一个比较“深“的文件夹里,所以命令显得又丑又长. 问题解决方案: 1.使用环境变量(修改.bashrc的方法) a.先查看自己的Mac目前正在用的是什么shell echo $SHELL 返回结果类似如下图 这里我是zsh,,也许你是bash,不过没关系,配置环境变量

sed与awk命令小结

1.sed命令小结 Sed是一个非交互式文本编辑器,它可对文本文件和标准输入进行编辑,标准输入可以是来自键盘输入.文件重定向.字符串.变量,甚至来自管道的文本.Sed从文本的一个文本行或标准输入中读取数据,将其复制到缓冲区,然后读取命令行或脚本的第一个命令,对此命令要求的行号进行编辑,重复此过程,直到命令行或脚本中的所有命令都执行完毕.相对于vi等其他文本编辑器,sed可以一次性处理所有的编辑任务,显得非常高效,为用户节省了大量的时间. 1. 语法:sed [OPTION]... {script