473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Timer...How to measure an event?

Hi,
How does one set up a timer so I can measure the time to do an event?

Something like this I guess the format would be,

start timer...

(do event)

....stop timer

display total time in seconds in a msg box


thanks,

Gary
Nov 22 '05 #1
3 1763
Depends on how much precision you need but since you asked for Seconds, try
this:

dim dtStart as DateTime = Now()
....stuff happens here
dim clockIt as Integer = CInt(DateDiff(DateInterval.Second, dtStart, Now())

messagebox.show(clockIt.ToString)
If you need higher precision look to QueryPerformanceCounter, and if you
need timing down to nearly the millisecond then you might want to look to a
multimedia timer. Examples of these are just a google away.

Robert Smith
Kirkland, WA
www.smithvoice.com

"Gary" <sp**@spam.net> wrote in message
news:R1*****************@news-server.bigpond.net.au...
Hi,
How does one set up a timer so I can measure the time to do an event?

Something like this I guess the format would be,

start timer...

(do event)

...stop timer

display total time in seconds in a msg box


thanks,

Gary

Nov 22 '05 #2
Gary,

Environment.tickcount does the trick.

Be aware that that is in milliseconds what is not even precious enough
because there is normally so much multiprocessing that you needs to do test
thousands of time to real get an answer.

There is as well the which looks more precise
Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef X As
Long) As Short

However read what I wrote above.

I hope this helps?

Cor
"Gary" <sp**@spam.net>
Hi,
How does one set up a timer so I can measure the time to do an event?

Something like this I guess the format would be,

start timer...

(do event)

...stop timer

display total time in seconds in a msg box


thanks,

Gary

Nov 22 '05 #3
Gary,
In addition to the other comments.

I normally use QueryPerformanceCounter, as its compatible with Performance
Counters. For example I can define a Performance Counter that shows Time Per
Operation very easily with QueryPerformanceCounter & the PerformanceCounter
class...

Following are some KB articles that show you how to use
QueryPerformanceCounter to time your code.

Use QueryPerformanceCounter to Time code in VB.NET:
http://support.microsoft.com/default...b;en-us;306978

Use QueryPerformanceCounter to Time code in C#:
http://support.microsoft.com/default...b;en-us;306979

Use QueryPerformanceCounter to Time code in C++ .NET:
http://support.microsoft.com/default...b;en-us;815668

NOTE: It appears that VS.NET 2005 (aka Whidbey, due out later in 2005) will
have a StopWatch class that internally will decide between
QueryPerformanceCounter & Environment.TickCount:

http://msdn2.microsoft.com/library/ebf7z0sw.aspx

Hope this helps
Jay

"Gary" <sp**@spam.net> wrote in message
news:R1*****************@news-server.bigpond.net.au...
Hi,
How does one set up a timer so I can measure the time to do an event?

Something like this I guess the format would be,

start timer...

(do event)

...stop timer

display total time in seconds in a msg box


thanks,

Gary

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gary | last post by:
Hi, How does one set up a timer so I can measure the time to do an event? Something like this I guess the format would be, start timer...
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
1
by: hstockbridge5 | last post by:
Hi, I read the KB article to create a stopwatch in Access 97 (http://support.microsoft.com/default.aspx?scid=kb;en-us;142871), but I'd like to do something a little different. Instead of...
3
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects...
8
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
4
by: Rich | last post by:
Hello, I am trying to measure the elapsed time between 2 processes. If I declare startTime As Double, endTime as Double and say startTime = Timer .... process1 ....
8
by: Xero | last post by:
Hello. Could anybody suggest a way to create a timer? I want to timer to be displayed to the user, telling he or she how much time has passed. Thanks. -- Xero
5
by: Jakub Moskal | last post by:
Hi, I want to write a benchmark that will measure performance of several different algorithms for the same problem. There is a set time bound though, the algorithm cannot run longer than n...
4
by: Boki | last post by:
Hi All, I have a timer, if my data queue Q has data, the timer should start work, if there is no data in Q, the timer should stop. However, there is an event can fire timer to start. Should I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.