Thursday, 14 May 2009

Timing program executions on Linux

Linux has a useful command to do this: time

The time command runs the specified program command with the given arguments. When command finishes, time writes a message to standard output giving timing statistics about this program run. These statistics consist of (i) the elapsed real time between invocation and termination, (ii) the user CPU time (the sum of the tms_utime and tms_cutime values in a struct tms as returned by times(2)), and (iii) the system CPU time (the sum of the tms_stime and tms_cstime values in a struct tms as returned by times(2)).

For example, if your c-shell script is called blah.csh and takes two arguments (say, arg_1 and arg_2), you can find out how long it takes to run by executing it as:
> time source blah.csh arg_1 arg_2


Macko Usko said...

koufalalinuxas mou egines

alla ta windows gia mmporg kala kratoun

pote tha pas katw?