Many .NET developers misuse the properties of DateTime structure and apply Now
for purposes where it’s not designed for which reduces the performance of the
code. UtcNow is what should be used for many cases
rather than Now, and even for timing measurements
there is a particular class called Stopwatch.
Seeing a quantitative comparison between these approaches
visualized in a simple diagram, you can understand why it’s recommended to use
each property or type in its own place. I am very sure that the misuse of these
options in the .NET codes written in the past decade has had a major impact on
many .NET applications and I hope that better training on this topic and
similar ones prevents such mistakes from happening.
I’ve uploaded the sample code for
this post that you can run on your machine to compare these three approaches
yourself.
Download
[Download
Sample]
The source code sample for this article is available for
download.