Solved

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

Posted on 2004-10-01
3
468 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 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