Does anyone have any experience and/or documentation concerning the accuracy
of the stopwatch class? How does it calculate the elapsed time? I read
somewhere Stopwatch could be used for performance testing of various methods
and would like to know how accurate it is.

Thanks,
Scott

Re: Accuracy of System.Diagnostics.Stopwatch by William

William
Thu Oct 20 01:37:24 CDT 2005

It is as accurate as how accurate DateTime.Now is. As it Timespan between
two DateTimes. I would guess 0-50ms delta on average.

--
William Stacey [MVP]

"Homer Simpson" <homer@moe's.com> wrote in message
news:%23e6wVzR1FHA.1132@TK2MSFTNGP10.phx.gbl...
> Does anyone have any experience and/or documentation concerning the
> accuracy of the stopwatch class? How does it calculate the elapsed time? I
> read somewhere Stopwatch could be used for performance testing of various
> methods and would like to know how accurate it is.
>
> Thanks,
> Scott
>
>
>



Re: Accuracy of System.Diagnostics.Stopwatch by Lloyd

Lloyd
Thu Oct 20 02:32:42 CDT 2005

I guess
aStopWatch.IsHighResolution is what you're after....

"Homer Simpson" <homer@moe's.com> wrote in message
news:%23e6wVzR1FHA.1132@TK2MSFTNGP10.phx.gbl...
> Does anyone have any experience and/or documentation concerning the
> accuracy of the stopwatch class? How does it calculate the elapsed time? I
> read somewhere Stopwatch could be used for performance testing of various
> methods and would like to know how accurate it is.
>
> Thanks,
> Scott
>
>
>



Re: Accuracy of System.Diagnostics.Stopwatch by Brian

Brian
Thu Oct 20 11:01:36 CDT 2005

Scott,

Check the Stopwatch.Frequency field. It will return the number of
ticks per second. I suspect the class wraps the
QueryPerformanceCounter and QueryPerformanceFrequency APIs if there is
a high resolution hardware counter on the box so it's likely to be very
accurate.

Brian

Homer Simpson wrote:
> Does anyone have any experience and/or documentation concerning the accuracy
> of the stopwatch class? How does it calculate the elapsed time? I read
> somewhere Stopwatch could be used for performance testing of various methods
> and would like to know how accurate it is.
>
> Thanks,
> Scott