Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand the output of time command?

Tags:

unix

I am trying to figure out the performance of my code, but I do not understand the output of the time command, Can anybody please explain what does time command output means.

The following is what I get:

time ./filereader   real    0m0.193s user    0m0.012s sys 0m0.056s 

What is real, user, sys?

like image 803
Avinash Avatar asked Aug 07 '10 21:08

Avinash


People also ask

What is time command output?

This is all elapsed time including time slices used by other processes and time the process spends blocked (for example if it is waiting for I/O to complete). User is the amount of CPU time spent in user-mode code (outside the kernel) within the process. This is only actual CPU time used in executing the process.

How does the time command work?

The time command is in no way related to the date command, which provides the system's date and time. Instead, it times a program or script's execution and tells you how long it took.

What is the command for output?

Use the OUTPUT command to: Direct the output from a job to your terminal. The output includes the job's job control language statements (JCL), system messages (MSGCLASS), and system output (SYSOUT) data sets.

How do you write time output in files?

How to make 'time' write its output to a file? If you want the time command to write its output to a file instead of the terminal, use the -o command line option, which expects a file name/path as input. This command will display ping's output on stdout, while the 'time' command output will be written to the text file.


1 Answers

From: http://zch051383471952.blogspot.com/2010/01/different-of-real-user-sys-time.html

Real refers to actual elapsed time; User and Sys refer to CPU time used only by the process.

  • Real is wall clock time - time from start to finish of the call. This is all elapsed time including time slices used by other processes and time the process spends blocked (for example if it is waiting for I/O to complete).
  • User is the amount of CPU time spent in user-mode code (outside the kernel) within the process. This is only actual CPU time used in executing the process. Other processes and time the process spends blocked do not count towards this figure.
  • Sys is the amount of CPU time spent in the kernel within the process. This means executing CPU time spent in system calls within the kernel, as opposed to library code, which is still running in user-space. Like 'user', this is only CPU time used by the process.
like image 132
NinjaCat Avatar answered Oct 17 '22 05:10

NinjaCat