Solved

dim Timer1 , Timer1.Start , run MyProcedure, Timer1.stop, how do i see how long the procedure took?

Posted on 2004-10-01
3
456 Views
Last Modified: 2011-09-20
hi, i want to time how long a procedure or sub or function takes to execute.
this is what i did so far, how can i get the value of timer1 to see how long timer1 ran for?

        Dim timer1 As New Timer
        timer1.Interval = 500
        timer1.Start()
          MyProcedure
        timer1.Stop()

thanks!
0
Comment
Question by:jxharding
3 Comments
 
LVL 12

Assisted Solution

by:monosodiumg
monosodiumg earned 250 total points
Comment Utility
The Timer object is more of an alarm clock than a stopwatch. It will trigger an event every Interval milliseconds from when you call Start to when you call Stop.
You can use it for timing but that's not what it's usually used for.
To time your proc, simply record the system time before and after and take the difference:

Dim OldTime As Date = Now
MyProcedure
Dim NewTime As Date = Now
Dim DifferenceInSeconds As Long = DateDiff(DateInterval.Second, OldTime, NewTime)
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 250 total points
Comment Utility
Don't use a timer for that just use the tickcount

dim int as integer = environment.tickcount
          MyProcedure

msgbox(environment.tickcount - int)


it gives the time in milliseconds
0
 

Author Comment

by:jxharding
Comment Utility
much better avenue of thought
thank you both!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now