Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: clock()

Author: Heiner Marxen

Date: 09:04:14 01/31/00

Go up one level in this thread


On January 31, 2000 at 11:13:49, James Robertson wrote:

>I am trying to get my program to compute the cpu % used under windows, and was
>hoping I could simple divide the time returned by clock() (supposedly the cpu
>time) by GetTickCount() (the wall clock time). Unfortunately, _both_ functions
>return wall clock time. What function instead of clock() should I use to find
>the cpu time used?

Bad luck!  Clock() is supposed to deliver the CPU time.  Citing from the
Standard (7.12.2.1):

The clock funtion returns the implementation´s best approximation
to the processor time used by the program since the beginning of an
implementation-defined era related only to the program invocation.

So, it is a matter of "quality of implementation".  Sorry.
For a better approximation you will have to use some OS-specific function,
if clock() is not good enough.

Heiner



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.