John G Duffy
August 24th, 2001, 08:32 AM
Here is a Loop that uses Timer() to record how long a loop takes.
A second Loop used Time() to track the same loop.
The two loops record sisgnificantly different results.
Anyone care to comment as to why and which is more accurate if either. I realize there is a Timer API I could be using but this is a curiosity.
option Explicit
'
private Sub Command1_Click()
Dim strt as Single, stp as Single, x as Long
strt = time()
Do Until x = 10000000
x = x + 1
Loop
stp = time()
print "time() " & stp - strt
End Sub
'
private Sub Command2_Click()
Dim strt as Single, stp as Single, x as Long
strt = Timer
Do Until x = 10000000
x = x + 1
Loop
stp = Timer
print "Timer " & stp - strt
End Sub
John G
A second Loop used Time() to track the same loop.
The two loops record sisgnificantly different results.
Anyone care to comment as to why and which is more accurate if either. I realize there is a Timer API I could be using but this is a curiosity.
option Explicit
'
private Sub Command1_Click()
Dim strt as Single, stp as Single, x as Long
strt = time()
Do Until x = 10000000
x = x + 1
Loop
stp = time()
print "time() " & stp - strt
End Sub
'
private Sub Command2_Click()
Dim strt as Single, stp as Single, x as Long
strt = Timer
Do Until x = 10000000
x = x + 1
Loop
stp = Timer
print "Timer " & stp - strt
End Sub
John G