News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

GetCpuFrequency Tests

Started by dedndave, October 13, 2015, 08:34:58 PM

Previous topic - Next topic

FORTRANS

Hi,

P-III

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
801818 KHz

Press any key to continue ...

Pentium M

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
632730 KHz

Press any key to continue ...

HTH,

Steve N.

Siekmanski

Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz Windows 8.1

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
3402080 KHz
Creative coders use backward thinking techniques as a strategy.

jj2007

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz

And no errors reported by GetLastError ::)

sinsi

Numbers 0-13 show straight away, then a wait for 14,15, speed=0
AMD A10-7850 3.70 GHz, Windows 7 Ultimate x64

edit: Same thing for i7-4790 3.60 GHz, Windows 10 Pro

nidud

#19
deleted

hutch--

No luck on my old i7.


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz

Press any key to continue ...

dedndave

dang - back to the drawing board
the one that makes me scratch my head is 22 KHz - lol
the 0's are a bit of a mystery, too - but one that probably has a simple fix that i am overlooking

thanks again, guys   :t

mabdelouahab

i5 / Win8.1 x64
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz

Press any key to continue ...

dedndave

yah - i have some work to do - lol

thought i had the bases covered
makes me feel like a novice   :(

Raistlin

Intel Core i5 HP Prodesk

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz

Press any key to continue ...


@Dave - thanks for personal mail btw
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

TouEnMasm

Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz
Microsoft Windows 10 Famille Version: 10.0.10240
-----------------------------------------------------------------------------------------------------------------
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz
-------------------------------------------------------------------------------------------------------------------
Press any key to continue ...
Fa is a musical note to play with CL

TouEnMasm

Perhaps a stupid question,why not used cpuid instruction to get the frequency
Fa is a musical note to play with CL

dedndave

that is the "design" frequency - the frequency that the manufacturer intended the processor to be used
i want to measure the actual clock frequency

honestly, i thought this would be easy - lol
in the old forum, Edgar came up with some code (and i wrote a program using it)
it seemed to work fairly well
however, that was before windows 8 and 10 (and newer processors, i guess)
also, i am doing some things differently

at the moment, i am time limited
my mom is in the hospital, and i have been spending every night with her
so - i get some time during the day, but i am somewhat exhausted - probably the reason for the errors   :P

FORTRANS

Hi Dave,

Quote from: dedndave on October 15, 2015, 02:04:56 PM
that is the "design" frequency - the frequency that the manufacturer intended the processor to be used
i want to measure the actual clock frequency

   Makes sense.  I guess it is accuracy that would make things
tricky.  A rough estimate with an ugly spread should be easy?

Quoteat the moment, i am time limited
my mom is in the hospital, and i have been spending every night with her
so - i get some time during the day, but i am somewhat exhausted - probably the reason for the errors

   Sorry to hear that.  I hope things are getting better.

Best of luck,

Steve N.

MichaelW

Running on my POS Windows 8.1-64 laptop, with a 2.16GHz Celeron, I get:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz


For a laptop I was expecting the clock speed to vary a lot, so in my code I did everything I could think of to maximize the resolution and accuracy, and surprisingly the variation is limited to the 6th decimal place.


;===============================================================================
include \masm32\include\masm32rt.inc
.686
;===============================================================================
.data
      pf      LARGE_INTEGER <>
      pc1     LARGE_INTEGER <>
      pc2     LARGE_INTEGER <>
      cc1     LARGE_INTEGER <>
      cc2     LARGE_INTEGER <>
      giga    REAL8 1000000000.0
      freq    REAL8 ?
.code   
;=============================================================================== 
start:
;===============================================================================

    invoke GetCurrentProcess
    mov     ebx, eax
   
    invoke SetProcessAffinityMask, ebx, 1
    invoke SetPriorityClass, ebx, REALTIME_PRIORITY_CLASS
   
    invoke GetCurrentThread
    invoke SetThreadPriority, eax, THREAD_PRIORITY_TIME_CRITICAL
   
    invoke Sleep, 2000
   
    invoke QueryPerformanceFrequency, ADDR pf
    ;printf("%I64d\n\n",pf.QuadPart)
   
    xor     eax, eax
    cpuid
    rdtsc
    mov     cc1.HighPart, edx
    mov     cc1.LowPart, eax
   
    invoke QueryPerformanceCounter, ADDR pc1

    invoke Sleep, 2000
   
    xor   eax, eax
    cpuid
    rdtsc
    mov     cc2.HighPart, edx
    mov     cc2.LowPart, eax

    invoke QueryPerformanceCounter, ADDR pc2
   
    ; elapsed counter cycles = pc2.QuadPart - pc1.QuadPart
    ; elapsed seconds = elapsed counter cycles / pf.QuadPart
    ; elapsed clock cycles = cc2.QuadPart - cc1.QuadPart
    ; clock speed = elapsed cycles / elapsed seconds
   
    fild    pc2.QuadPart
    fild    pc1.QuadPart
    fsub
    fild    pf.QuadPart
    fdiv
    fild    cc2.QuadPart
    fild    cc1.QuadPart
    fsub
    fdivr
    fld     giga
    fdiv
    fstp    freq

    printf("%fGHz\n\n", freq)   
   
    inkey
    exit
end start
;===============================================================================

Well Microsoft, here's another nice mess you've gotten us into.