Below an example for Output of Windows System time
Part of the results normal on my system :
2010-9-16 4 18:14:29.328
2010-9-16 4 18:14:29.328
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.343
2010-9-16 4 18:14:29.359
There you see the reason why a timer resolution is about 1/60 second.
Windows obviosly switched to the applications process in 15 to 16 milliseconds.
Again. There are Windows functions to (temporarily) speed up the process switching.
timeBeginPeriod() and timeEndPeriod()
By using that the result improves:
2010-9-16 4 20:38:40.740
2010-9-16 4 20:38:40.741
2010-9-16 4 20:38:40.745
2010-9-16 4 20:38:40.746
2010-9-16 4 20:38:40.749
2010-9-16 4 20:38:40.751
2010-9-16 4 20:38:40.754
2010-9-16 4 20:38:40.755
But anyway - I think - the result will be depend on how many processes running.
- Code: Select all
Type SYSTEMTIME
wYear As short
wMonth As short
wDayOfWeek As short
wDay As short
wHour As short
wMinute As short
wSecond As short
wMilliseconds As short
End Type
Declare Sub GetSystemTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME)
Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As integer) As integer
Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As integer) As integer
/*
see the difference with and without
timeBeginPeriod(1)
timeEndPeriod(1)
http://gpwiki.org/index.php/VB:Timers
*/
Sub Main()
Dim I As Integer
Dim strC as string
Dim stmT1 as SYSTEMTIME
timeBeginPeriod(1)
log "Increased Frequence"
For I = 1 to 20
GetSystemTime(stmT1)
log ( stmT1.wYear & "-" & stmT1.wMonth & "-" & stmT1.wDay & " " & stmT1.wDayOfWeek & " " & _
stmT1.wHour & ":" & stmT1.wMinute & ":" & stmT1.wSecond & "." & stmT1.wMilliseconds )
next
timeEndPeriod(1)
log "Normal Frequence"
For I = 1 to 20
GetSystemTime(stmT1)
log ( stmT1.wYear & "-" & stmT1.wMonth & "-" & stmT1.wDay & " " & stmT1.wDayOfWeek & " " & _
stmT1.wHour & ":" & stmT1.wMinute & ":" & stmT1.wSecond & "." & stmT1.wMilliseconds )
next
? "Press any key to continue.."
do
strC = inkey
loop while strC = ""
end sub
Main()
3