Much frequently,I use GetTickCount API to test my code.
For example:
LOCAL var :DWORD
invoke GetTickCount
mov var,eax
someLoop........
invoke GetTickCount
sub eax,var
PrintDec eax
I execute the above code about 10 times and I take the average value.
This code works OK in Win9x,and WinMe,
but now that I have WinXP this code does not works properly.
I take values with long variations.
What about this ?
Regards,
Manos.
GetTickCount doesn't always generate enough accuracy. You need to use RDTSC and to set the process priority to real time. Look at MichaelW's post about macros that do timing.
or use QueryPerformance-Counter/Frequency
Quote from: lifewire on January 22, 2005, 06:52:25 PM
or use QueryPerformance-Counter/Frequency
QueryPerformanceCounter actually does a RDTSC itself, but it has extra overhead because you are calling a procedure. So doing RDTSC manually causes less overhead in your timing code. Here is an example of setting the priority class. It is VERY important for getting consistent timings.
invoke GetCurrentProcess
invoke SetPriorityClass,eax,REALTIME_PRIORITY_CLASS
Manos,
I have not had problems with GetTickCount() but I did with Win2k until I set the process priority.
invoke SetPriorityClass,FUNC(GetCurrentProcess),REALTIME_PRIORITY_CLASS
invoke GetTickCount
push eax
; ---------------------
; run your code here
; ---------------------
invoke GetTickCount
pop ecx
sub eax, ecx
fn MessageBox,hWnd,str$(eax),str$(rcnt),MB_OK
invoke SetPriorityClass,FUNC(GetCurrentProcess),NORMAL_PRIORITY_CLASS
Yes,you are right.
With Win2K and later,the solution is the pair:
SetPriorityClass,FUNC(GetCurrentProcess),REALTIME_PRIORITY_CLASS
SetPriorityClass,FUNC(GetCurrentProcess),NORMAL_PRIORITY_CLASS
Thanks All,
Manos.