This article says that first of all you need to compare three alternatives, Stopwatch
, DateTime.Now
AND DateTime.UtcNow
.
It also shows that in some cases (when performance counter doesn't exist) Stopwatch is using DateTime.UtcNow + some extra processing. Because of that it's obvious that in that case DateTime.UtcNow is the best option (because other use it + some processing)
However, as it turns out, the counter almost always exists - see Explanation about high-resolution performance counter and its existence related to .NET Stopwatch?.
Here is a performance graph. Notice how low performance cost UtcNow has compared to alternatives:
The X axis is sample data size, and the Y axis is the relative time of the example.
One thing Stopwatch
is better at is that it provides higher resolution time measurements. Another is its more OO nature. However, creating an OO wrapper around UtcNow
can't be hard.