Purpose
The PerfTimer keyword class lets you set an incremental timer with millisecond accuracy.
Example
Dim t as PerfTimer
Dim i as Integer
Dim l as Integer
l= 10000000
Debug "Testing loop performance for " & l & " loops..."
t.Start
For i = 1 to l
Next i
Debug Str(t.ElapsedMs) & "ms"
Debug Str(t.ElapsedSeconds) & "s"
Debug "Approximately " & l/t.ElapsedSeconds & " loops per second"
Debug "Approximately " & l*2/t.ElapsedSeconds & " lines per second"
Debug "Testing 100ms loop with GiveTime..."
l = 0
t.Start
t.SetExpiryMs(100)
Do While NOT t.IsExpired
l = l + 1
GiveTime
Loop
Debug Str(t.ElapsedMs) & "ms"
Debug Str(t.ElapsedSeconds) & "s"
Debug Str(l) & " loops"
Debug "Testing 1s loop with GiveTime..."
l = 0
t.SetExpirySeconds(1)
Do While NOT t.IsExpired
l = l + 1
GiveTime
Loop
Debug Str(t.ElapsedMs) & "ms"
Debug Str(t.ElapsedSeconds) & "s"
Debug Str(l) & " loops"
|