How to find execution time of any command or script



To know how much time a command has elapsed from invocation to completion of execution could be useful.

We may want to test a script to know how much time it takes to complete its task, before we push it on a production linux box.

This can be achieved very simply on Linux.

Syntax: time (command|script)




In the command above we have tested how much time it takes for "who" to complete.

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. See below for a brief description of kernel mode (also known as 'supervisor' mode) and the system call mechanism.


Note: Real,User & Sys definitions are excerpts from http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1.. as i found them better to my knowledge :)

Comments

  1. hi akash how are you doing,

    this is krishna from bangalore indfosys , oracle dba..

    ReplyDelete

Post a Comment

Popular posts from this blog

scp data from server behind proxy / firewall / dmz

How to add command alias in linux