gpelley
May 18th, 2002, 10:31 PM
Hi all
I'm trying to work out how to return an estimation of processor speed, but without luck. Under Windows NT/2000/XP I can simply read the corresponding keys of the registry, but I would like an alternative way of doing it.
I've played around with various API's, but with no success.
I'm currently trying to get it to work using the high-performance counters to measure the specific time taken to perform a given calculation, but at the moment it returns the same results on a Pentium II 266 as it does on an Athlon Tbird 1GHz, so there's obviously something going wrong somewhere. Could you please tell me if I'm going about it the right way with my code below (am I using the QueryPerformance functions properly?): -
' ============= MY CODE : ================
Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type
' CUSTOM DATA TYPE TO HANDLE LARGE INTEGERS
Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long
Declare Function QueryPerformanceCounter Lib "kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As LARGE_INTEGER) As Long
' I DECLARE THE API FUNCTIONS HERE
dim constFreq as LARGE_INTEGER
dim time1 as LARGE_INTEGER
dim time2 as LARGE_INTEGER
dim outTime as Double
dim timeDif as Long
' VARIABLE DECLERATIONS
QueryPerformanceCounter(lpPerformanceCount)
lpPerformanceCount = time1
' QUERY OF PERFORMANCE COUNTER BEFORE THE EQUATION
' MY CALCULATIONS TO TIME GOES HERE
QueryPerformanceCounter(lpPerformanceCount)
lpPerformanceCount = time2
' QUERY OF PERFORMANCE COUNTER AFTER THE EQUATION
QueryPerformanceFrequency(lpFrequency)
lpFrequency = constFreq
' QUERY THE PERFORMANCE FREQUENCY (CONSTANT - CPU SPECIFIC)
timeDif = time2-time1
outTime = timeFif/constFreq
' CALCULATE PERFORMANCE RATIO
' I OUTPUT THE RESULTS HERE
' =========== END OF CODE =============
Also, is the CpuID source code as provided by Intel & AMD freely distributable, and how do I make use of it simply to detect CPU speed?
I'm quite new to VB, so really I need just some simple to understand code that will make a rough estimation of CPU speed.
Any help would be very much apreciated.
All the very best,
Gav
I'm trying to work out how to return an estimation of processor speed, but without luck. Under Windows NT/2000/XP I can simply read the corresponding keys of the registry, but I would like an alternative way of doing it.
I've played around with various API's, but with no success.
I'm currently trying to get it to work using the high-performance counters to measure the specific time taken to perform a given calculation, but at the moment it returns the same results on a Pentium II 266 as it does on an Athlon Tbird 1GHz, so there's obviously something going wrong somewhere. Could you please tell me if I'm going about it the right way with my code below (am I using the QueryPerformance functions properly?): -
' ============= MY CODE : ================
Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type
' CUSTOM DATA TYPE TO HANDLE LARGE INTEGERS
Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long
Declare Function QueryPerformanceCounter Lib "kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As LARGE_INTEGER) As Long
' I DECLARE THE API FUNCTIONS HERE
dim constFreq as LARGE_INTEGER
dim time1 as LARGE_INTEGER
dim time2 as LARGE_INTEGER
dim outTime as Double
dim timeDif as Long
' VARIABLE DECLERATIONS
QueryPerformanceCounter(lpPerformanceCount)
lpPerformanceCount = time1
' QUERY OF PERFORMANCE COUNTER BEFORE THE EQUATION
' MY CALCULATIONS TO TIME GOES HERE
QueryPerformanceCounter(lpPerformanceCount)
lpPerformanceCount = time2
' QUERY OF PERFORMANCE COUNTER AFTER THE EQUATION
QueryPerformanceFrequency(lpFrequency)
lpFrequency = constFreq
' QUERY THE PERFORMANCE FREQUENCY (CONSTANT - CPU SPECIFIC)
timeDif = time2-time1
outTime = timeFif/constFreq
' CALCULATE PERFORMANCE RATIO
' I OUTPUT THE RESULTS HERE
' =========== END OF CODE =============
Also, is the CpuID source code as provided by Intel & AMD freely distributable, and how do I make use of it simply to detect CPU speed?
I'm quite new to VB, so really I need just some simple to understand code that will make a rough estimation of CPU speed.
Any help would be very much apreciated.
All the very best,
Gav