Here is the video version, if you prefer it:
If you are a software developer, you sometimes want to know how much time does your program need to execute. Or, if you are a “regular” Linux user, maybe you want to know how much time a command takes to execute (albeit most likely not). Here is how to measure it: (Ward, 2014)
mislav@mislavovo-racunalo:~$ time ls
There are 3 relevant times: (“What do ‘real’, ‘user’ and ‘sys’ mean in the output of time(1)?,” n.d.)
realtime – the amount of CPU time from starting the call to finishing the call of the process; this includes the time your process waited for some resource and the time the processor was executing other processes (your processor can switch to another process and execute a fraction of that process, then get back to the execution of your process)
usertime – the amount of CPU time spent within the process
systime – the amount of CPU time spent in the kernel within the process; if you wanted to do some stuff that only the kernel can do (remember that a regular user can’t do everything), you call the kernel function to do that and then this gets added up to
The CPU time your process takes up is
user + sys time.
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 178-179
What do “real”, “user” and “sys” mean in the output of time(1)? (n.d.). Retrieved February 14, 2020, from https://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1
Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.