Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Measuring clock cycles: The easy way

Author: Vincent Diepeveen

Date: 05:09:22 08/08/00

Go up one level in this thread


On August 08, 2000 at 05:19:39, Alexander Kure wrote:

>Hi James,
>
>#include <time.h>
>
>clock_t start = clock();
>
>// do what ever you want to measure
>
>clock_t stop = clock() - start;
>
>printf("Elapsed time in seconds: %.2f", (double) stop / CLOCKS_PER_SEC");
>
>Function clock() returns the number of clock ticks of elapsed processor time for
>the current process.

Under windows clock() is nice.

However if you use a win32 interface then setting a timer
will give times using gettickcount() which is more accurate as clock()
is. Most likely under windows clock() is enough.

Under linux DO NOT USE clock(), as it gives overflow each 72 minutes.

>Greetings
>Alex



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.