Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obtain processor's velocity
Message
From
02/10/2002 09:39:27
 
 
To
02/10/2002 09:09:48
Emerson Reed
Folhamatic Tecnologia Em Sistemas
Americana - São Paulo, Brazil
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00706818
Message ID:
00706831
Views:
17
>How can I obtain processor's velocity (ex: 600 Mhz, 1 Ghz, etc)?

The easiest way is to get the system CPU identifier information using GetSystemInfo(), which returns a structure returning information about the processor type and stepping, and then given that as a benchmarking point, run a long, CPU-intensive loop and time it. The less time it takes to run, the faster the processor; you'll need approximate base benchmarks for a variety of CPUs to use this mechanism.

The prototype for the API call is as follows, assuming that you use ClsHeap to create a receiving buffer whose address you pass to the function. You'd need to do this to ensure that pointers remain static when the buffer is returned to VFP, since VFP strings can be shuffled around in memory, thereby invalidating any embedded pointers:
DECLARE GetSystemInfo IN WIN32API INTEGER lpSystemInfo
A SystemInfo structure is returned in the buffer whose address is passed to the API call; you'll have to parse it and retrieve several strings whose pointers are embedded in the structure. You might want to check Christof Lange's STRUCT class to see if he's already built support for handling a SystemInfo structure into the class, rather than using ClsHeap as I demonstrate here:
SET PROCEDURE TO ClsHeap ADDITIVE
oHeap = CREATEOBJ('Heap')
DECLARE GetSystemInfo IN WIN32API INTEGER lpSystemInfo
nBufferPointer = oHeap.Alloc(512) && more than adequate for both the structure and strings
=GetSystemInfo(@nBufferPointer)
cVFPBuffer = oHeap.CopyFrom(nBufferPointer)
*
*  Extract the members you need using the UDFs in ClsHeap
*
oHeap.DeAlloc(nBufferPointer)
oHeap = NULL
ClsHeap is fairly extensively commented; it describes how to use its functions to decode and retrieve various things using pointers embedded in structures.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform