Hi
I sometimes get complaints about execution speed from my customers. So I had the idea to add a simple CPU benchmark into my application in order to find out how slow (fast) their processors are.
My idea: count how many times a loop with a simple calculation can be executed in 0.05s (short enough to be hardly recognizable). Of course I know, that there are many other factors making a system slow or fast (e.g. disk access), but as a rough measure this would be a nice indicator.
I order to get a more stable result I decided not to use TIMER, but QueryPerformanceCounter.
Hmm, this will not work at all. The problem seems to be different possible values for 'qFreq'. It will have a much higher value on old systems than on a modern system. And the calculation will behave completely different, making the results incomparable.
Has anyone got an idea, how to find the aproximative CPU speed without this problem.
I sometimes get complaints about execution speed from my customers. So I had the idea to add a simple CPU benchmark into my application in order to find out how slow (fast) their processors are.
My idea: count how many times a loop with a simple calculation can be executed in 0.05s (short enough to be hardly recognizable). Of course I know, that there are many other factors making a system slow or fast (e.g. disk access), but as a rough measure this would be a nice indicator.
I order to get a more stable result I decided not to use TIMER, but QueryPerformanceCounter.
Code:
Function RelativePerformance() As single #Register None LOCAL qFreq As Quad LOCAL qOverhead As Quad LOCAlqStart As Quad local qStop As Quad Local i As Long LOCAl x As Double QueryPerformanceFrequency qFreq QueryPerformanceCounter qStart ' Intel suggestion. First use may be suspect QueryPerformanceCounter qStart ' So, wack it twice <smile> QueryPerformanceCounter qStop qOverhead = qStop - qStart ' Relatively small, could e neglected for my problem QueryPerformanceCounter qStart i = 0 DO i = i + 1 QueryPerformanceCounter qStop LOOP UNTIl (((qStop - qStart - qOverhead)*1000/qFreq)>50) '1/20 second END FUNCTION
Has anyone got an idea, how to find the aproximative CPU speed without this problem.
Comment