Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Measuring clock cycles

Author: Larry Griffiths

Date: 10:49:50 08/09/00

Go up one level in this thread


On August 09, 2000 at 13:22:27, James Robertson wrote:

>On August 08, 2000 at 23:33:49, Larry Griffiths wrote:
>
>>I use the Read time stamp counter in my program sometimes, it looks like this...
>>
>>
>>#ifdef	INCLUDE_TIMERS
>>#define	StartTimer(start)\
>>	{\
>>	asm\
>>		{\
>>		db	0fh,31h;\
>>		mov 	dword ptr start+4,EDX;\
>>		mov	dword ptr start,EAX;\
>>		}\
>>	}
>>#define	StopTimer(stop)\
>>	{\
>>	asm\
>>		{\
>>		db	0fh,31h;\
>>		mov 	dword ptr stop+4,EDX;\
>>		mov	dword ptr stop,EAX;\
>>		}\
>>	}
>>#endif
>>
>>unsigned __int64	rdtscstart;
>>unsigned __int64	rdtscstop;
>>unsigned __int64	rdtscelapsed=0;
>>
>>StartTimer(rdtscstart);
>>... code goes here...
>>StopTimer(rdtscstop);
>>
>>rdtscelapsed=rdtscstop-rdtscstart;
>>
>>// the 550,000,000 is the clock speed of my processor.
>>
>>double	dresult=(double)rdtscelapsed/(double)550000000;
>>char	result[64];
>>sprintf(result,"%f",dresult);
>>
>>Larry.
>
>Thanks. I'll try this out.... :)
>
>James

One other note:

My experience with the rdtsc instruction on earlir Pentiums is that it can take
40 to 50 cpu cycles to execute.  I have not tested it with my Pentium III xeon
machine.

Larry.



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.