Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-10-01
3
Medium Priority
?
475 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 1000 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 1000 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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

926 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