### Author Topic: GetCpuFrequency Tests  (Read 16163 times)

#### FORTRANS

• Member
• Posts: 990
##### Re: GetCpuFrequency Tests
« Reply #15 on: October 14, 2015, 05:48:16 AM »
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

• Member
• Posts: 1432
##### Re: GetCpuFrequency Tests
« Reply #16 on: October 14, 2015, 06:34:04 AM »
Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz Windows 8.1

Code: [Select]
`0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 153402080 KHz`
Creative coders use backward thinking techniques as their strategy.

#### jj2007

• Member
• Posts: 8352
• Assembler is fun ;-)
##### Re: GetCpuFrequency Tests
« Reply #17 on: October 14, 2015, 06:51:19 AM »
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

• Member
• Posts: 1040
##### Re: GetCpuFrequency Tests
« Reply #18 on: October 14, 2015, 06:53:14 AM »
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
I can walk on water but stagger on beer.

#### nidud

• Member
• Posts: 1462
##### Re: GetCpuFrequency Tests
« Reply #19 on: October 14, 2015, 07:30:08 AM »
May be random but the CPU string seems to include the frequency in newer hardware.

#### hutch--

• Member
• Posts: 5338
• Mnemonic Driven API Grinder
##### Re: GetCpuFrequency Tests
« Reply #20 on: October 14, 2015, 08:08:37 AM »
No luck on my old i7.

Code: [Select]
`0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 150 KHzPress any key to continue ...`
hutch at movsd dot com
http://www.masm32.com

#### dedndave

• Member
• Posts: 8787
• Still using Abacus 2.0
##### Re: GetCpuFrequency Tests
« Reply #21 on: October 14, 2015, 08:44:17 AM »
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

#### mabdelouahab

• Member
• Posts: 364
##### Re: GetCpuFrequency Tests
« Reply #22 on: October 14, 2015, 08:53:45 AM »
i5 / Win8.1 x64
Code: [Select]
`0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 150 KHzPress any key to continue ...`

#### dedndave

• Member
• Posts: 8787
• Still using Abacus 2.0
##### Re: GetCpuFrequency Tests
« Reply #23 on: October 14, 2015, 02:39:11 PM »
yah - i have some work to do - lol

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

#### Raistlin

• Member
• Posts: 310
##### Re: GetCpuFrequency Tests
« Reply #24 on: October 14, 2015, 04:09:19 PM »
Intel Core i5 HP Prodesk

Code: [Select]
`0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 150 KHzPress any key to continue ...`
@Dave - thanks for personal mail btw

#### ToutEnMasm

• Member
• Posts: 1190
##### Re: GetCpuFrequency Tests
« Reply #25 on: October 15, 2015, 01:48:31 AM »
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

#### ToutEnMasm

• Member
• Posts: 1190
##### Re: GetCpuFrequency Tests
« Reply #26 on: October 15, 2015, 01:59:42 AM »
Perhaps a stupid question,why not used cpuid instruction to get the frequency
Fa is a musical note to play with CL

#### dedndave

• Member
• Posts: 8787
• Still using Abacus 2.0
##### Re: GetCpuFrequency Tests
« Reply #27 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

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

#### FORTRANS

• Member
• Posts: 990
##### Re: GetCpuFrequency Tests
« Reply #28 on: October 15, 2015, 11:36:15 PM »
Hi Dave,

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?

Quote
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

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

Best of luck,

Steve N.

#### MichaelW

• Global Moderator
• Member
• Posts: 1209
##### Re: GetCpuFrequency Tests
« Reply #29 on: October 16, 2015, 07:54:05 PM »
Running on my POS Windows 8.1-64 laptop, with a 2.16GHz Celeron, I get:
Code: [Select]
`0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 150 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.

Code: [Select]
`;===============================================================================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    exitend start;===============================================================================`
Well Microsoft, here’s another nice mess you’ve gotten us into.