Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Measuring clock cycles

Author: Larry Griffiths

Date: 20:33:49 08/08/00

Go up one level in this thread


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.




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.