Solved

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

Posted on 2004-10-01
3
467 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
[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
3 Comments
 
LVL 12

Assisted Solution

by:monosodiumg
monosodiumg earned 250 total points
ID: 12198693
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
ID: 12198696
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
ID: 12198891
much better avenue of thought
thank you both!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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