Re: clock()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Alex (sdfjkhsdkh_at_ksfjdkjwdfsklj.nowhere)
Date: 07/07/04


Date: Wed, 07 Jul 2004 14:44:19 -0400

Victor Bazarov <v.Abazarov@comAcast.net> wrote in news:
#gH7pzEZEHA.992@TK2MSFTNGP10.phx.gbl:

> Is it a known issue that in VC++ RTL the function 'clock()'
> reports the wall clock instead of CPU time used?
I've recently hit few problems with several time functions
implementations. In MSVC5 'clock' returns the difference between
'_ftime' from the start of the process. Considering that '_ftime'
returns wall clock, 'clock' won't provide you with the CPU (or
process) time for the calling process. And if the system time on the
host has been adjusted during the life of your application you may
get some strange results from 'clock'. Besides, time(0) also had a
problems MSVC5, but they have apparently been fixed in MSVC7 (look
for the recent thread).

<snip>
>
> I know of GetProcessTimes() function, but couldn't 'clock()'
> be implemented to use it?
GetProcessTimes is not available in 95 family, so 'clock' would have
to be implemented differently depending on windows OS family (not
that I'm against it :->).

Alex.



Relevant Pages

  • Re: Another Tricky Problem I am Messing With (Not Homework)
    ... Well, yeah, it's supposed to tell you how long the program has ... However this isn't what clock() measures. ... must be sharing that CPU time with all the other programs I'm running, ... it seems to ignorant me that a "multi-tasking" single ...
    (comp.lang.c)
  • how can I get the CPU time of a process?
    ... I'm interested in a user command and in a C-function. ... How can I track the number of overflows, without regularly calling clock()? ... CPU time of the process from the beginning, ...
    (comp.unix.misc)
  • Re: Need help with ICETOOL Time masks please
    ... CPU TIME fields to display. ... counter where the bit positions of the clock are numbered 0 to 63. ... CONVERT AS BINARY INT TO DECIMAL ...
    (bit.listserv.ibm-main)
  • Re: time output in milliseconds
    ... That time period could be a fixed date ... >> the clock() function could return the same value. ... >That typically means that clock returns an estimate of the CPU time ... >would be conforming. ...
    (comp.lang.c)
  • Re: to find execution time
    ... >> cah you please tell me how to find the execution time of a program in c. ... >Call clock() at the start of your program; call clockat the end of ... Note that you get the CPU time used by the program this way. ... Dan Pop ...
    (comp.lang.c)