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
?
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.
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.
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 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With