This is sourcecode for a VFP FLL (needs to be compiled with Visual C++) to determine the speed of a CPU, and the determination of the CPU speed is written in Assembler, faster isn't possible...
Call it from VFP as follows:
Code:
#include "pro_ext.h"
// Originally written by Roberto Ianni
// Modified by Rob444
void FAR SpeedTest(ParamBlk FAR *parm)
{
__int64 BeginCycle = 0, EndCycle = 0;
unsigned __int64 nCtr = 0, nFreq = 0, nCtrStop = 0;
// Obtains the frequency per second
if(QueryPerformanceFrequency((LARGE_INTEGER *) &nFreq))
{
// Obtains the value of the current counter
QueryPerformanceCounter((LARGE_INTEGER *) &nCtrStop);
// Add the counter to the frequency
nCtrStop += nFreq;
_asm
{
// Obtain the beginning of the cycle from the CPU clock
_emit 0x0f
_emit 0x31
mov DWORD PTR BeginCycle, eax
mov DWORD PTR [BeginCycle + 4], edx
}
do{
// retrieve the value of the performance counter
// until 1 sec has gone by:
// Waits for one second
QueryPerformanceCounter((LARGE_INTEGER *) &nCtr);
}while (nCtr < nCtrStop);
_asm
{
// Obtains the CPU clock cycles again, but after one second
_emit 0x0f
_emit 0x31
mov DWORD PTR EndCycle, eax
mov DWORD PTR [EndCycle + 4], edx
}
}
// EndCycle-BeginCycle is the speed in Hz,
// which, divided by 1,000,000, is the speed in MHz.
_RetFloat( ((float)EndCycle-(float)BeginCycle) / 1000000, 20, 8 );
}
FoxInfo myFoxInfo[] =
{
{"CPUSpeed", (FPFI) CPUSpeed, 0, ""}
};
extern "C" {
FoxTable _FoxTable =
{
(FoxTable *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
}
Call it from VFP as follows:
Code:
SET LIBRARY TO "MyFLL.fll"
? CPUSpeed()
SET LIBRARY TO