Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Measuring clock cycles

Author: James Robertson

Date: 10:20:13 08/09/00

Go up one level in this thread


On August 08, 2000 at 13:11:55, J. Wesley Cleveland wrote:

>On August 08, 2000 at 02:34:54, James Robertson wrote:
>
>>On August 08, 2000 at 01:54:48, Andrew Dados wrote:
>>
>>>On August 08, 2000 at 00:25:06, James Robertson wrote:
>>>
>>>>I am trying to measure clock cycles for certain functions in my program. Could
>>>>sombodey please explain how to do this? Totally simple methods are preferred. :)
>>>>
>>>>Thanks!
>>>>James
>>>
>>>All modern CPUs starting with Pentium and K2 have TSC 64 bit counter which gets
>>>incremented by 1 for each CPU clock.
>>>Under protected mode reading from this counter is by default disabled, but for
>>>some reason any task can enable instruction for reading TSC.
>>>
>>>(I'll be quoting asm code I wrote before some instructions were supplied by C
>>>inline asm, so in some cases I had to define instructions myself)
>>>
>>>enabling TSC:
>>>
>>>asm
>>
>>Thanks, this looks cool. Unfortunately, I don't know how to interpret the db
>>instructions... how can I use them in VC++?
>>
>
>This works in VC++ and compiles to just a rdtsc instruction.
>
>#pragma warning(disable:4035)
>inline __int64 Timer_ReadTSC_sys(void)
>{
> __asm rdtsc
>}

Very elegant; thanks.

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.