On Wed, 8 Jun 2005, Matthew Miller wrote:
On Wed, Jun 08, 2005 at 07:28:39AM -0700, Globe Trotter wrote:The bash commando 'time' gives real, user and system time of a command. see 'man time' for more information. Perhaps that could be usefull.Thanks, however the issue is that it gives results on the entire program, not the algorithm part. Matthew Miller indicates that clock() approximately does what I want, so I will just use that.
clock() or the more detailed-if-you-have-sub-processes times() call basically returns to your program exactly what the bash 'time' command would.
Only if it's the first and last thing your program does. If you want to time only the "solve" step of a program that does
read input solve problem write output
then BASH time won't help.
times(2) (or rusage(2)) is better in some other ways than clock(3) also. For example, it apparently doesn't wrap after 72 minutes.
-- Matthew Saltzman
Clemson University Math Sciences mjs AT clemson DOT edu http://www.math.clemson.edu/~mjs