TGrimace
10-28-2002, 03:26 PM
Is there a command in BASH that will show you how long the program took to execute? For example `echo $?` shows if the last command was successfully executed, isn't there somthing that tells how long it took?
|
Click to See Complete Forum and Search --> : length of time question TGrimace 10-28-2002, 03:26 PM Is there a command in BASH that will show you how long the program took to execute? For example `echo $?` shows if the last command was successfully executed, isn't there somthing that tells how long it took? bwkaz 10-28-2002, 06:15 PM Not directly, but if you look at the "time" command, it will probably do what you want. The difference is that using time, you have to know when you start that you want to time the program. If there was a bash variable, it wouldn't matter... hmm... I'm pretty sure there isn't one, but it wouldn't be too hard to do, what with process accounting and all that... Stuka 10-28-2002, 07:36 PM bwkaz: you were more right than you know (and so very wrong too! :P ) From the man page for time(1)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)). bwkaz 10-28-2002, 09:35 PM Err, what? Oh... when I said "there isn't one", I meant a bash variable or something like that. I know there's a "time" command... :D Stuka 10-29-2002, 12:57 PM oooh...ok then...:D bwkaz 10-29-2002, 01:37 PM Ooh! Idea! I could hack a variable that does do that into bash! When it fork()s off a process, it starts a timer (or something; I haven't thought this through all the way yet), then whenever a process ends, it sets the variable(s) to the different times... system, user, CPU, etc. I wonder if anyone's thought of that before... hmm. In any case, I'd wait to start that until after Christmas. Too much work this semester in Real Life (or at least college). TGrimace 10-29-2002, 01:38 PM Cool. I just figured out how to use the time command. The man pages are a bit misleading, but trial-and-error will always show the way, eventually. :D Thanks guys! justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |