Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes performance insights for DateTime.Now.
Cause
System.DateTime.Now
is resulting in slow performance.
Performance insight description
DateTime.Now
is costly because it determines daylight savings time (DST) using TimeZoneInfo.GetIsDaylightSavingsFromUtc()
. Consider using DateTime.UtcNow
instead of DateTime.Now
.
Frequent calls to this method can be expensive if DateTime is used to calculate time deltas, such as measuring the duration of certain activities. In this scenario, check whether using DateTime.UtcNow
can be used instead.
How to investigate a warning
In the CPU Usage tool, click View source code to go to the call tree and source line highlighting view, which shows where the most amount of time is spent in System.DateTime.Now
. From this point, trace back to where the method is used and check whether you can use DateTime.UtcNow
instead.