Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Measuring clock cycles

Author: James Robertson

Date: 10:22:27 08/09/00

Go up one level in this thread


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



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.