-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
Reviewing a customer issue, we noticed any accidental usage of DateTimeOffset.Now has a noticeable impact to startup:
277ms is a lot of time given that the total startup time is 182ms of a dotnet new android app in Release mode. (It's also possible that 277ms is somewhat inflated by tracing)
If I record a custom AOT profile (to avoid JIT-ting), the time is better, but still shows up:
In this case, it would be better to use UtcNow, but I could see a lot of developers might run into this on accident. Is there anything we could do to improve this? Thanks!
Reproduction Steps
dotnet new android- Open
MainActivity.csand put_ = DateTimeOffset.Now;in theOnCreate()method. - Build/run with
dotnet build -c Release -t:Run
Expected behavior
DateTimeOffset.Now doesn't significantly slow down an Android app.
Actual behavior
DateTimeOffset.Now does seem to significantly slow down an Android app.
Regression?
No
Known Workarounds
Use UtcNow?
Configuration
I tested this with the .NET 6.0.400-preview.22301.10 SDK, and the SR 1 version of .NET MAUI.
Other information
Here is dotnet trace output:
One is default settings (code path is JIT), and the second is using an AOT profile (code path is AOT).
Metadata
Metadata
Assignees
Type
Projects
Status

