|
-
Sep 20th, 2000, 05:45 AM
#1
Thread Starter
Fanatic Member
I'm would like to time how long two or three different methods return records from SQL statements.
Can anybody tell me how I'd go about this?
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
-
Sep 20th, 2000, 05:54 AM
#2
Fanatic Member
No doubt i will get flamed for the use of the timer function, as everyone seems to insist it is not accurate enough, and they use the API.
But in my humble opinion, most of the people on this site seem to have forgotten the number 1 rule of programming.
Keep it simple whenever possible.
Code:
Dim sngTime As Single
sngTime = Timer
'execute code
MsgBox Timer - sngTime
Iain, thats with an i by the way!
-
Sep 20th, 2000, 06:10 AM
#3
Thread Starter
Fanatic Member
Cheers.
Seem to be getting wierd results (I am running it in Access) which are saying that it is taking no time to return the results of the queries.
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
-
Sep 20th, 2000, 06:20 AM
#4
Fanatic Member
If that is the case, then i am guessing that the query takes under 60ms. You could try the getTickCount API i suppose.
Code:
'IN MODULE
Public Declare Function GetTickCount Lib "kernel32" () As Long
'CODE
Dim lTime As Long
lTime = GetTickCount
'CODE
MsgBox GetTickCount - lTime
Iain, thats with an i by the way!
-
Sep 20th, 2000, 06:30 AM
#5
transcendental analytic
Querryperformance counter is the next step, you'll get an error diffusion up to one microsecond, 1/1000 of gettickcount.
Code:
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Dim Start as currency, Finish as currency, Freq as currency
QueryPerformanceCounter Start
'your code you want to performance check
QueryPerformanceCounter Finish
QueryPerformanceFrequency Freq
Msgbox CDbl(Finish - Start) * CDbl(Freq) * 1000) & "microseconds"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 20th, 2000, 06:58 AM
#6
Fanatic Member
*sigh*
Ok, i knew there would be one. If you want to start getting all offical about it. Lets take into acount the API overhead as well.
Code:
Option Explicit
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Private Sub Form_Load()
Time_Addition
End Sub
Private Sub Time_Addition()
Dim ctr1 As Currency, ctr2 As Currency, cFreq As Currency
Dim cOverhead As Currency, lNum As Long, I As Long
'get the frequency
QueryPerformanceFrequency cFreq
QueryPerformanceCounter ctr1
QueryPerformanceCounter ctr2
'determine API overhead
cOverhead = ctr2 - ctr1
'start timing loop
QueryPerformanceCounter ctr1
For I = 1 To 10000000
lNum = lNum + 1
Next I
'get the end time
QueryPerformanceCounter ctr2
Debug.Print "("; ctr1; "-"; ctr2; "-"; cOverhead; ") /"; cFreq
Debug.Print I - 1 & " additions took";
Debug.Print (ctr2 - ctr1 - cOverhead) / cFreq; "seconds"
End Sub
Iain, thats with an i by the way!
-
Sep 20th, 2000, 07:15 AM
#7
Thread Starter
Fanatic Member
Cor blimey! Turn my back for two minutes to go to lunch and I get loads of replies. 
I tried the GetTickCount way before I posted my question here and had the same results as with the Timer method.
I've now tried the QueryPerformanceCounter method and all is working well apart from the fact that the one that should be quickest is the slowest!!
Thanks for all your help.
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
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
|