Skip to content
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

Fix two Swift profiling bugs #3954

Merged
merged 2 commits into from
Nov 19, 2022
Merged

Conversation

nesevis
Copy link
Contributor

@nesevis nesevis commented Nov 9, 2022

This PR fixes:

  • A hard crash in the ProfilingATNSimulator initialiser, from attempting to set values via subscript on an empty array.
  • A bug in ProfilingATNSimulator.adaptivePredict's method that meant .timeInPrediction would always report zero; this has now replaced by the preferred way to measure time in Swift.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
nesevis Chris Kolbu
The initialiser creates an empty array. This means that indexed subscripts will be out of range.

The Swift compiler amortises `.append` to effectively O(1).

Signed-off-by: Chris Kolbu <chris.kolbu@ittybittyapps.com>

Verified

This commit was signed with the committer’s verified signature. The key has expired.
nesevis Chris Kolbu
The current implementation using date object did not actually work (e.g the `timeInPrediction` was always zero). This has now been replaced by the preferred way to measure time in Swift.

See discussion: https://forums.swift.org/t/recommended-way-to-measure-time-in-swift/33326

Signed-off-by: Chris Kolbu <chris.kolbu@ittybittyapps.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants