# Measuring time differences precisly under Windows - Programmer

This is a discussion on Measuring time differences precisly under Windows - Programmer ; Hi! I'm currently developing a tool which reads voltages from an USB-AD-converter and outputs time/voltage pairs. Therefore I need a way of measuring the time as precise as possible (microseconds). The best way I found to do so in standard ...

# Thread: Measuring time differences precisly under Windows

1. ## Measuring time differences precisly under Windows

Hi!

I'm currently developing a tool which reads voltages from an
USB-AD-converter and outputs time/voltage pairs. Therefore I need a way
of measuring the time as precise as possible (microseconds).

The best way I found to do so in standard C(++) was
clock()/double(CLK_TCK), which is obviously not a really good solution.
Another solution would be time(), but that function is far away from the
accuracy I wish to achive.

As the program is only required to run under the Windows operating
system, I don't need to keep with standard C; so I want to know whether
there is a way to measure times (finally I only need the time since the
start of the measurement (which is approximately the start of the
program), so I don't neccessarily need "absolute values" like returned
by time()), and how to do so to achive the most exact results.

Thank you very much!
Yours,
Dominik Wallner

2. ## Re: Measuring time differences precisly under Windows

Dominik Wallner wrote:
> I'm currently developing a tool which reads voltages from an
> USB-AD-converter and outputs time/voltage pairs. Therefore I need a way
> of measuring the time as precise as possible (microseconds).
>
> The best way I found to do so in standard C(++) was
> clock()/double(CLK_TCK), which is obviously not a really good solution.
> Another solution would be time(), but that function is far away from the
> accuracy I wish to achive.
>
> As the program is only required to run under the Windows operating
> system, I don't need to keep with standard C; so I want to know whether
> there is a way to measure times (finally I only need the time since the
> start of the measurement (which is approximately the start of the
> program), so I don't neccessarily need "absolute values" like returned
> by time()), and how to do so to achive the most exact results.

I found a solution on another group. Here it is for those interested:
http://www.geisswerks.com/ryan/FAQS/timing.html

Greetings,
Daniel