?
Solved

Capture sub second response times in VB

Posted on 2002-05-30
7
Medium Priority
?
260 Views
Last Modified: 2010-05-02
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
Comment
Question by:mkeysaer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 300 total points
ID: 7045720
Take a look at the API function:
Declare Function GetTickCount Lib "kernel32" () As Long

Anthony
0
 
LVL 1

Expert Comment

by:Toad224
ID: 7046047
Use    Timer    ...  it gives it in times accurate lessa than a second by returning a single...  ie. 82390.95

Good Luck.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 7046484
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.

 
LVL 4

Expert Comment

by:mcoop
ID: 7046542
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
 
LVL 1

Expert Comment

by:Toad224
ID: 7046703
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
 
LVL 2

Expert Comment

by:Crin
ID: 7047015
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
 

Author Comment

by:mkeysaer
ID: 7047569
A lot of good answers.  Thanks for the input everyone!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question