Link to home
Start Free TrialLog in
Avatar of vally
vally

asked on

C++ Timer

I am currently writing a program using Visual C++ under Windows 95.
I would like to be able to time a peripherial device down to as accurate a time as possible, if possible in micro seconds. Is there any functions / techniques that will be able to give me this accurate a method of timing.

This program has to be accurate on various machines with different clock speeds.
The only solution I can find is the Performance Counter, but this is not always supported.
Avatar of vally
vally

ASKER

Edited text of question
You'll need to do a couple of things:

Use the multimedia timer: timeSetEvent().

However, timeSetEvent is not really accurate, so that you can do is use timeSetEvent for a one-time event, 1 millisecond before the actual time. Then when the timer fires, use QueryPerformanceCounter() to count until the actual time has occurred.
Avatar of vally

ASKER

When I said time it down, I meant as in how long it took to finish its task, eg transfer a block of data.

Besides QueryPerformanceCounter is out as it is not always supported
QueryPerformanceCounter() is supported on Pentuims and above, Pentium clones, Alphas, etc.  What more do you need?

Thui, your answer sounds strangely familiar :-)
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial