Time a command or a program

The command time <command> times a <command>, where the <command> can be a program or a Linux command. However, there are more precise ways of measuring the execution time for parts of a program, which you will learn about in various classes.

For example:

[alice@localhost cs253]$ time sleep 4

real    0m4.020s
user    0m0.000s
sys     0m0.000s
[alice@localhost cs253]$

The command time gives the “real” (elapsed) time followed by time spent by the CPU in user mode as well in system mode. Due to programs potentially waiting for input and due to multiple users on a system the user plus system time is usually less than the real time reported by thetime command.