• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Capture sub second response times in VB

I am writing a utility to use for performance testing.  Does anyone know of a VB function I can invoke to capture sub second response times or a way that I can create my own.  The standard now() function only returns the value of the system clock which does not break down the time futher than a second.  Likewise the date functions do not support sub second time intervals either.
0
mkeysaer
Asked:
mkeysaer
1 Solution
 
Anthony PerkinsCommented:
Take a look at the API function:
Declare Function GetTickCount Lib "kernel32" () As Long

Anthony
0
 
Toad224Commented:
Use    Timer    ...  it gives it in times accurate lessa than a second by returning a single...  ie. 82390.95

Good Luck.
0
 
Ryan ChongCommented:
I'm with Anthony, you can write you codes to test the time bypassed like this:

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub Command1_Click()
    Dim strTime As Long, stpTime As Long
    strTime = GetTickCount
   
    'Do the process here
    For i = 1 To 1000
        DoEvents
        Debug.Print i
    Next i
   
    'strTime returns time in miliseconds (1000 = 1 second)
    strTime = GetTickCount - strTime
   
    'Convert it to 2 decimal format
    MsgBox Format$(strTime / 1000, "#.00")
End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mcoopCommented:
I thought ticks are approx 18mS resolution... ?  (i.e. backward compatible with the old DOS clock...)

Does anyone know the correct answer ??

Sorry ryancs - I just want to make sure for my own knowledge as well !
0
 
Toad224Commented:
Yea... but  Timer  is basically the VB way of doing it...  like you would use MsgBox rather than the MessageBox Win API or like you would do text1.text = ""  rather than SendDlgItemMessage or SendMessage w/ WM_SETTEXT   Both ways work great, though

Good luck!
0
 
CrinCommented:
Hi,
When I developed profiler application for myself I used this:

Private Type SYSTEMTIME
  wYear As Integer
  wMonth As Integer
  wDayOfWeek As Integer" & ProfSpecLine
  wDay As Integer" & ProfSpecLine
  wHour As Integer" & ProfSpecLine
  wMinute As Integer" & ProfSpecLine
  wSecond As Integer" & ProfSpecLine
  wMilliseconds As Integer" & ProfSpecLine
End Type

Private Declare Sub GetSystemTime Lib ""kernel32"" (ByRef lpSystemTime As SYSTEMTIME)

After that you can do

Dim A as SYSTEMTIME
GetSystemTime A

and access A.wYear ... A.wMilliseconds.

Sincerely,
Crin

0
 
mkeysaerAuthor Commented:
A lot of good answers.  Thanks for the input everyone!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now