'timing' tricks in Win32
- Posted by wolfgang fritz <wolfritz at king.igs.net> Aug 15, 2000
- 457 views
I've been using the following high-performance counter -include- to more accurately time things in win32lib programs. ( ..as if that's possible under multi-tasking ) The question is, if I do something silly like this: include timer.e get_start() include win32lib.ew get_end() ...what *exactly*, is it, that I'm timing ? Wolf [] --start timer.e-- include dll.e include machine.e object myjk atom myarg, myt1, myt2, myspeed, mydiff myarg=allocate(4) constant mykernel32=open_dll("kernel32.dll"), myctr=define_c_func( mykernel32,"QueryPerformanceCounter",{C_INT},C_INT), myfreq=define_c_func( mykernel32,"QueryPerformanceFrequency",{C_INT},C_INT) myjk=c_func(myfreq,{myarg}) if myjk = 0 then printf(1,"%s\n",{"sorry, NO COUNTER FOUND !"}) abort(0) end if global procedure get_start() myjk=c_func(myfreq,{myarg}) myspeed=peek4u(myarg) myjk=c_func(myctr,{myarg}) myt1=peek4u(myarg) end procedure global procedure get_end() object myhandle myjk=c_func(myctr,{myarg}) myt2=peek4u(myarg) mydiff=myt2-myt1 myhandle=open("runtime.txt","w") printf(myhandle,"run time=%f seconds\n\n",{mydiff/myspeed}) close(myhandle) free(myarg) end procedure --end code--