TweeZz
TweeZz

Reputation: 4909

Is using DateTime.Now really something to worry about?

I just read http://aspalliance.com/2062_The_Darkness_Behind_DateTimeNow and started to wonder if this is really something to worry about.. The graph in the article clearly shows that using DateTime.Now is 'much' slower then using DateTime.UtcNow. Is this graph meaningful for any application you have written? Is this something you noticed yourself? Should I be changing my code not to use DateTime.Now anymore? Basically, have you ever noticed yourself a slowdown by using DateTime.Now? Can I go sleep without worrying about my miseducation of using DateTime.Now?

Upvotes: 0

Views: 322

Answers (2)

Ed Swangren
Ed Swangren

Reputation: 124642

As is the answer to any preconceived performance issue, test it. Does your app call DateTime.Now many many times in some performance critical section of code? If not than I severely doubt it will cause you any appreciable problems, and even if you do you should still test it to see how much slowdown the call causes relative to the entire operation.

Upvotes: 2

Paul
Paul

Reputation: 36319

No, hasn't impacted any app I've written. That said, UtcNow is useful beyond perf stuff if you're designing server-based software, since your users may span timezones.

Upvotes: 2

Related Questions