DateTime.UtcNow and DateTime.Now performance improvements in .NET 6

DateTime.UtcNow is significantly faster in .NET 6 compared to .NET 5. The performance improvement mainly comes from negating the regressions incurred when leap seconds support was added in .NET Core 3.

We can see from below that DateTime.Now performance is also improved… and in case you didn’t know, overall DateTime.UtcNow is a lot quicker than DateTime.Now!!!

Click the image for a larger view in a new tab…

These performance improvements can make a big difference when we need a unique DateTime per loop iteration rather than a single DateTime which can be set outside our loops. 

Leave a Reply

Your email address will not be published. Required fields are marked *