|
-
Nov 10th, 2000, 04:44 PM
#1
Thread Starter
Registered User
Hello!
I have a question for all you!
I was wondering how i can time a Loop like For i = 1 to 6000, i would like to time it how long it owuld take to loop threw that, but i have no idea how i am suppose to time it....does anyone else?
if you do please post it!
thanks for listening! 
-
Nov 10th, 2000, 04:58 PM
#2
Use GetTickCount.
Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command1_Click()
Start = GetTickCount
For I = 0 To 60000
Next I
Pause = GetTickCount
MsgBox "It took " & Pause - Start & " milliseconds"
End Sub
-
Nov 10th, 2000, 05:01 PM
#3
Frenzied Member
The easiest way is to use the timer keyword, this gives the number of seconds since the computer was booted (or something) accurate to 100th of a second so you could do something like this
Code:
Private Sub Command1_Click()
Dim x As Single
Dim i As Long
x = Timer
For i = 0 To 10000000
Next i
x = Timer - x
MsgBox "The loop took " & x & " seconds."
End Sub
kedaman and others are now going to tell you about the wonders of GetTickCount and QueryPerformanceTimer, but this is good enough for modt things.
-
Nov 10th, 2000, 05:18 PM
#4
Thread Starter
Registered User
Cool It works!
Thanks guys!
See what i'm trying to do is time 1 kind of loop and then time another one to see witch one goes faster, can someone tell me another way to do the same thing but with maybe a slower way to loop threw it?
like a differnet syntx for looping with the time and stuff included still.
Thanks
-
Nov 10th, 2000, 05:35 PM
#5
Sam Finch: Whether or not others tell the wonders of GetTickCount and QPC is besides the point. In this case, using QPC or GetTickCount would be better because as your loops get smaller, Timer will not be able to measure it correctly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|