-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt ISO8601FormatStyle on newer platforms #637
Comments
Hey! I would be happy to help with this if it's not already picked up! 😊 |
Thank you @arthurcro - go ahead! 👍 |
@arthurcro thanks for getting stuck in! Just a note that we don't currently have benchmarks in the repo, and we're about to migrate the CI to GitHub Actions. This shouldn't block you working on the issue, but it might delay us landing it, as we'd like to get this in place. I'll try and schedule that work this week. |
@arthurcro I expedited this to ensure you're unblocked to work on this when you get to it. The CI is updated. We have an open PR to add package benchmarks: apple/swift-openapi-runtime#119. And it looks like this should be a good patch...
As part of the work, it would be good to remove those benchmarks against foundation, once we have comparable numbers for the |
Thank you @simonjbeaumont, I appreciate it! I will start on this issue as soon as possible. I'll make sure to also update the benchmarks and remove the ones against foundation. |
Hey @czechboy0, I made an early draft MR on my fork but while running the tests I noticed
I tried reproducing the issue in a Swift playground, and got the same results. Also, parsing the formatted date with the same let initialDate = Date(timeIntervalSince1970: 1_674_036_251.123)
let formatStyle = Date.ISO8601FormatStyle.iso8601
.year()
.month()
.day()
.time(includingFractionalSeconds: true)
let encoded = initialDate.formatted(formatStyle)
print(encoded) // prints 2023-01-18T10:04:11.122 instead of 2023-01-18T10:04:11.123
print(initialDate == (try! formatStyle.parse(encoded)) // prints false |
@arthurcro that's interesting, can you open an issue against https://github.com/swiftlang/swift-foundation if you manage to reproduce it on a minimal project that doesn't include Swift OpenAPI Generator? |
@czechboy0 definitely, it's reproducible in a brand new Swift playground with only the code snippet I charged. I just opened an issue here swiftlang/swift-foundation#963. |
Motivation
ISO8601FormatStyle is significantly faster than ISO8601DateFormatter.
Proposed solution
Use #available to dynamically use the faster and more modern implementation in ISO8601FormatStyle, fall back to ISO8601DateFormatter otherwise (today's behavior).
We should also add benchmarks to the runtime package while we're there to measure the improvement.
Alternatives considered
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: