such as CPU time, memory, input and output, and so on. A special note is that some of the information is not visible on Linux. This is because the allocation function of some resources on Linux is not the same as the time instruction preset, so that the time instruction cannot obtain the data.
Grammar
Time [options] COMMAND [arguments]
Parameters:
- -O or--output=file: Sets the result output file. This option writes the output of time to the specified file. If the file already exists, the system will overwrite its contents.
- -A or--append: When used with-O, the results are written to the end of the file without overwriting the original content.
- -F FORMAT or--format=format: Sets the display in the format string. When this option is not set, the system preset format is used. However, you can use the environment variable time to set this format, so you do not have to log in every system to set once.
The time directive can display four major resources, respectively:
- Time Resources
- Memory Resources
- IO Resources
- Command Info
Detailed content is as follows:
1, Time Resources
E the time it takes to execute the instruction, in the form of: [Hour]:minute:second. Please note that this number does not represent the actual CPU time.
E the time, in seconds, that the instruction takes to execute. Please note that this number does not represent the actual CPU time.
The time, in seconds, that is spent in core mode (kernel mode) when the S instruction executes.
The amount of time, in seconds, that is spent in user mode when the U-command executes.
The ratio of CPU occupancy when P executes instructions. In fact, this number is the core mode plus the user mode CPU time divided by the total time.
2, Memory Resources
The maximum amount of solid memory that is occupied by M when executed. Unit is KB
The average, in kilobytes, of the entity memory that is used when the T executes
The average amount of memory (Stack+data+text) used by the K-executing program, in kilobytes
The average size, in kilobytes, of the unshared data area of the D Execution Program (KB)
The average size, in kilobytes, of its own stack (unshared stack) for the P-executing program
X average of shared text between execution programs, in kilobytes
The size, in bytes, of the Z-system memory page. It's a constant for the same system.
3. IO Resources
F the number of major memory page errors that this program has occurred. The main memory page error is a memory page that has been replaced in the replacement file (swap file) and has been assigned to another program. The contents of the page must be read again from the replacement file.
R the number of secondary memory page errors that this program has occurred. The so-called secondary memory page error refers to a memory page that has been replaced in a displacement file but has not been assigned to another program. The contents of the page are not corrupted at this time and do not need to be read from the replacement file.
W the number of times this program is swapped to the replacement file
c the number of times this program is forced to break (like the CPU time allocated to it)
W This program breaks down voluntarily (as if waiting for an I/O to finish, like a disk read, etc.)
I the number of files entered in this program
o Number of files exported by this program
R the Socket message received by this program
s the Socket message sent by this program
K The number of signals (Signal) received by this program
4. Command Info
C execution parameters and instruction names
End code for x directives (Exit Status)
-P or--portability: This option automatically sets the display format to:
Real%e user%usys%s: The purpose of this is to be compatible with the POSIX specification.
-V or--verbose: This option lists all the resources used in all programs, not only in English, but also in general. It's very useful for people who don't want to take the time to familiarize themselves with formatting or just start touching the instructions.
Instance
1. # Time Date
2. Sun Mar 22:45:34 GMT-8 2006
3.
4. Real 0m0.136s
5. User 0m0.010s
6. SYS 0m0.070s
7. #
In the above instance, execute the command "time Date" (see Line 1th).
The system executes the command "date" first, and the execution result of the 2nd behavior command "date".
The 第3-6 behavior executes the time statistic result of the command "date", where line 4th "real" is the actual time, the 5th line "user" is the user's CPU time, and the 6th line "SYS" is the system CPU time.
The display format for the above three types of time is mmmnn[. Fff]s.
Use the following instructions
Time-v Ps-aux
We can get the results of executing ps-aux and the system resources spent. The information listed below is as follows:
USER PID%cpu%mem VSZ RSS TTY STAT START time COMMAND
Root 1 0.0 0.4 1096 472? S Apr19 0:04 Init
Root 2 0.0 0.0 0 0? SW Apr19 0:00 [kflushd]
Root 3 0.0 0.0 0 0? SW Apr19 0:00 [Kpiod]
......
Root 24269 0.0 1.0 2692 996 PTS/3 R 12:16 0:00 ps-aux
Command being timed: "Ps-aux"
User Time (seconds): 0.05
System Time (seconds): 0.06
Percent of CPU This job got:68%
Elapsed (Wall Clock) time (H:MM:SS or M:SS): 0:00.16
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): 0
Average resident set Size (Kbytes): 0
Major (requiring I/O) page faults:238
Minor (Reclaiming a frame) page faults:46
Voluntary context switches:0
Involuntary context switches:0
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