Can Stopwatch be used in production code?

Posted by Adrian on Stack Overflow See other posts from Stack Overflow or by Adrian
Published on 2010-05-10T18:30:18Z Indexed on 2010/05/10 18:44 UTC
Read the original article Hit count: 357

Filed under:
|
|
|

Hi, I need an accurate timer, and DateTime.Now seems not accurate enough. From the descriptions I read, System.Diagnostics.Stopwatch seems to be exactly what I want.

But I have a phobia. I'm nervous about using anything from System.Diagnostics in actual production code. (I use it extensively for debugging with Asserts and PrintLns etc, but never yet for production stuff.) I'm not merely trying to use a timer to benchmark my functions - my app needs an actual timer. I've read on another forum that System.Diagnostics.StopWatch is only for benchmarking, and shouldn't be used in retail code, though there was no reason given. Is this correct, or am I (and whoever posted that advice) being too closed minded about System.Diagnostics? ie, is it ok to use System.Diagnostics.Stopwatch in production code? Thanks Adrian

© Stack Overflow or respective owner

Related posts about c#

Related posts about timer