[TriLUG] clock() from time.h

Randall Barlow randall_barlow at ncsu.edu
Thu May 18 13:59:05 EDT 2006


Rodney Radford wrote:
> The man page states that clock "returns an approximation of processor time used by the program", which matches what you are getting under Linux. However, this link, http://www.cygwin.com/ml/cygwin/2003-10/msg01086.html, implies that under a Windows box clock actually returns the sum of the user-used-time and the system-used-time - ie: wall clock time. Now that doesn't answer your question of 'why', but does agree with what you are seeing.  Perhaps the issue is that Windows doesn't differentiate between windows and user time, or any time per process.
>
> Which did you want to see - system time or wall-clock time as perhaps there is a better solution than using clock().
My intention was to see wall-clock time - do you know of something that 
will give me this in both windows and linux?  If not, do you know 
something that will under linux (and I can just use preprocessor 
directives to check whether I am in Linux or Windows at compile time...)

Randy




More information about the TriLUG mailing list