hi
i have been using the sleep statement a lot lately.
there was a posting in just previously posting about timers and measuring the sleep time.
i do not know much at all about timers and measuring time, what timing routine does best for what, just basically confusion on a beginners part.
i believe the below timer code can from David Roberts and altered by John Gleason.
could somebody shed some light on what all this means.
i am referring to the sleep statement and other timer functions in general.
i wrote this program to see what the timer function would show after some sleep statement.
because windows is a multitasking system, a program in many situations is going to have to deal with timers of sorts.
thanks in advance for any responses
paul
here are my results on my laptop with windows 2000 pro.
i have been using the sleep statement a lot lately.
there was a posting in just previously posting about timers and measuring the sleep time.
i do not know much at all about timers and measuring time, what timing routine does best for what, just basically confusion on a beginners part.
i believe the below timer code can from David Roberts and altered by John Gleason.
could somebody shed some light on what all this means.
i am referring to the sleep statement and other timer functions in general.
i wrote this program to see what the timer function would show after some sleep statement.
because windows is a multitasking system, a program in many situations is going to have to deal with timers of sorts.
thanks in advance for any responses
paul
Code:
'pb 4.04 ' #COMPILE EXE #DIM ALL DECLARE FUNCTION QueryPerformanceCounter LIB "KERNEL32.DLL" ALIAS "QueryPerformanceCounter" (lpPerformanceCount AS QUAD) AS LONG DECLARE FUNCTION QueryPerformanceFrequency LIB "KERNEL32.DLL" ALIAS "QueryPerformanceFrequency" (lpFrequency AS QUAD) AS LONG '~~~~~~~~~~~A Variation of Dave Roberts' MACRO Timer~~~~~~~~~~~~~~~~~~~~~~~ MACRO onTimer LOCAL qFreq, qOverhead, qStart, qStop AS QUAD LOCAL f AS STRING f = "#.###" 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 END MACRO MACRO goTimer = QueryPerformanceCounter qStart MACRO stopTimer = QueryPerformanceCounter qStop MACRO showTimer = USING$(f,(qStop - qStart - qOverhead)*1000000/qFreq /1000) + " milliseconds" '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FUNCTION PBMAIN () AS LONG LOCAL I AS LONG ' i used the sleep statement just before its use in an effort to try keep the cpu instructions of sleep in the cpu cache onTimer gotimer SLEEP 1 stoptimer FOR i=0 TO 22 STEP 1 SLEEP 1 gotimer SLEEP i stoptimer STDOUT "sleep "+STR$(I)+" = "+showtimer NEXT I STDOUT "press any key to continue WAITKEY$ SLEEP 1 FOR i=22 TO 45 STEP 1 SLEEP 1 gotimer SLEEP i stoptimer STDOUT "sleep "+STR$(I)+" = "+showtimer NEXT I STDOUT "press any key to continue WAITKEY$ SLEEP 1 FOR i=46 TO 69 STEP 1 SLEEP 1 gotimer SLEEP i stoptimer STDOUT "sleep "+STR$(I)+" = "+showtimer NEXT I STDOUT "press any key to continue WAITKEY$ FOR i=0 TO 300 STEP 10 SLEEP 1 gotimer SLEEP i stoptimer STDOUT "sleep "+STR$(I)+" = "+showtimer NEXT I STDOUT "press any key to continue WAITKEY$ END FUNCTION
Code:
sorry, not code just wanted scroll bars for viewing purposes sleep 0 = 0.003 milliseconds sleep 1 = 15.605 milliseconds sleep 2 = 15.614 milliseconds sleep 3 = 15.605 milliseconds sleep 4 = 15.618 milliseconds sleep 5 = 15.630 milliseconds sleep 6 = 15.629 milliseconds sleep 7 = 15.426 milliseconds sleep 8 = 15.618 milliseconds sleep 9 = 15.608 milliseconds sleep 10 = 15.617 milliseconds sleep 11 = 16.177 milliseconds sleep 12 = 15.617 milliseconds sleep 13 = 16.287 milliseconds sleep 14 = 15.932 milliseconds sleep 15 = 15.619 milliseconds sleep 16 = 31.251 milliseconds sleep 17 = 31.253 milliseconds sleep 18 = 31.305 milliseconds sleep 19 = 31.243 milliseconds sleep 20 = 32.164 milliseconds sleep 21 = 31.244 milliseconds sleep 22 = 31.236 milliseconds press any key to continue sleep 22 = 31.247 milliseconds sleep 23 = 31.267 milliseconds sleep 24 = 31.747 milliseconds sleep 25 = 31.247 milliseconds sleep 26 = 31.238 milliseconds sleep 27 = 31.309 milliseconds sleep 28 = 31.246 milliseconds sleep 29 = 31.260 milliseconds sleep 30 = 31.237 milliseconds sleep 31 = 31.267 milliseconds sleep 32 = 46.868 milliseconds sleep 33 = 46.431 milliseconds sleep 34 = 46.871 milliseconds sleep 35 = 46.883 milliseconds sleep 36 = 46.867 milliseconds sleep 37 = 46.874 milliseconds sleep 38 = 46.885 milliseconds sleep 39 = 46.866 milliseconds sleep 40 = 46.875 milliseconds sleep 41 = 46.651 milliseconds sleep 42 = 46.877 milliseconds sleep 43 = 46.867 milliseconds sleep 44 = 46.929 milliseconds sleep 45 = 46.884 milliseconds press any key to continue sleep 46 = 46.874 milliseconds sleep 47 = 62.472 milliseconds sleep 48 = 62.495 milliseconds sleep 49 = 62.425 milliseconds sleep 50 = 62.473 milliseconds sleep 51 = 62.504 milliseconds sleep 52 = 62.516 milliseconds sleep 53 = 62.496 milliseconds sleep 54 = 62.493 milliseconds sleep 55 = 62.489 milliseconds sleep 56 = 62.530 milliseconds sleep 57 = 62.962 milliseconds sleep 58 = 62.557 milliseconds sleep 59 = 62.506 milliseconds sleep 60 = 62.514 milliseconds sleep 61 = 62.584 milliseconds sleep 62 = 62.508 milliseconds sleep 63 = 78.038 milliseconds sleep 64 = 78.112 milliseconds sleep 65 = 78.126 milliseconds sleep 66 = 78.119 milliseconds sleep 67 = 78.119 milliseconds sleep 68 = 78.109 milliseconds sleep 69 = 78.121 milliseconds press any key to continue sleep 0 = 0.083 milliseconds sleep 10 = 15.914 milliseconds sleep 20 = 31.223 milliseconds sleep 30 = 31.244 milliseconds sleep 40 = 46.896 milliseconds sleep 50 = 62.497 milliseconds sleep 60 = 62.519 milliseconds sleep 70 = 78.117 milliseconds sleep 80 = 93.947 milliseconds sleep 90 = 94.271 milliseconds sleep 100 = 109.356 milliseconds sleep 110 = 125.008 milliseconds sleep 120 = 125.013 milliseconds sleep 130 = 140.628 milliseconds sleep 140 = 140.690 milliseconds sleep 150 = 156.266 milliseconds sleep 160 = 171.897 milliseconds sleep 170 = 171.923 milliseconds sleep 180 = 187.430 milliseconds sleep 190 = 203.138 milliseconds sleep 200 = 203.129 milliseconds sleep 210 = 220.623 milliseconds sleep 220 = 234.400 milliseconds sleep 230 = 234.416 milliseconds sleep 240 = 250.019 milliseconds sleep 250 = 249.998 milliseconds sleep 260 = 265.645 milliseconds sleep 270 = 280.569 milliseconds sleep 280 = 281.232 milliseconds sleep 290 = 296.889 milliseconds sleep 300 = 312.524 milliseconds press any key to continue
Comment