Bash Time

The bash time command reports three times:

  1. real: The wall clock time. The time for the process you started to finish as measured by your wrist watch.
  2. user: This is the CPU time spent in user mode.
  3. sys: This is CPU time spent in kernel mode (i.e. system calls).

Real Time

The real time can be very skewed. For example, a file copy to a floppy drive may take a microsecond of CPU time, yet take up to 10 seconds of wall clock (real) time.

Additionally, this time includes the time that other   unrelated processes run, while the program to be benchmarked is swapped out, on a multi-tasking OS. Therefore, for benchmarking a given program, the real time will increase dramatically on a fully loaded machine in comparison to a machine with very little load.

You would think that real = user + sys, and in general, that might be approximately true. However, on SMP systems, this will not be the case.

CPU Time

The user and sys time are both CPU time. This is the amount of time the CPU spends on the given process.

User time is the time spent executing commands in user mode or time spent in user mode libraries (i.e. printf, malloc, strlen, fopen, fread, etc).

System (sys) time is the time spent executing commands in kernel mode. This includes hardware reading/writing and system calls (brk, read, write, open, etc).

GNU Time

If you use "time", you are using the time command provided by bash. However, if you use "\time", then you are using the time program that is provided by GNU. GNU's time give a WHOLE LOT more information than bash time. In particular, see the -p and -v options. However, bash time gives you millisecond (10^-3 sec) precision while GNU time only gives you centisecond (10^-2 sec), so bash's time is more precise.