Time used to count the total times that command execution took
Example one:
Time ls bin etc Games include Java lib lib64 libexec local sbin share src tmpreal 0m0.004suser 0m0.001ssys 0m0.002s
- Real time is the wall clock time, which is the time the command starts executing to the end. This short time includes the time slices that other processes occupy, and the time it takes to block the process.
- User time is the CPU time that the process spends in user mode, which is the only time that is really spent executing the process, and the time in other processes and spending blocking states is not counted.
- SYS time is the amount of CPU time spent in kernel mode, representing the time it takes to take a system call in the kernel, which is the CPU time actually used by the process.
Example two, comparing the time difference between different algorithms
[Email protected] test]# Time forIinch`seq 1111`; Docount=${#i}; DoneReal 0m0.036suser 0m0.024ssys 0m0.021s[[email protected] test]# Time forIinch`seq 1111`; DoCount= 'Echo$i |WC-M '; DoneReal 0m5.985suser 0m1.618ssys 0m5.729s[[email protected] test]# Time forIinch`seq 1111`; DoCount= 'ExprLength $i '; DoneReal 0m3.938suser 0m1.163ssys 0m3.225s
It can be seen that the algorithm with ${#var} is optimal
The output information shows the real time, user time, and sys time spent by this command, respectively. Real time is the wall clock time, which is the time the command starts executing to the end. This short time includes the time slices that other processes occupy, and the time it takes to block the process. User time is the CPU time that the process spends in user mode, which is the only time that is really spent executing the process, and the time in other processes and spending blocking states is not counted. SYS time is the amount of CPU time spent in kernel mode, representing the time it takes to take a system call in the kernel, which is the CPU time actually used by the process.
From: Http://man.linuxde.net/time
The Joy of Linux commands--time