Repository navigation
feat(js/ts): support System.Diagnostics.Stopwatch - #5100
Merged
Merged
Conversation
This was referenced Oct 16, 2026
Member
|
Thank you for the PR. I made a quick pass and would like to add some small improvements myself. I will not be able to do it before the beginning of next week, so I am converting it to draft in the meantime to prevent an accidental merge. No action is needed from you. |
MangelMaxime
marked this pull request as draft
October 16, 2026 20:41
Built on performance.now(), as the Python and Beam targets already support Stopwatch. Fixes fable-compiler#5099
MangelMaxime
force-pushed
the
stopwatch
branch
from
October 21, 2026 17:51
33856d5 to
b3616dd
Compare
MangelMaxime
marked this pull request as ready for review
October 21, 2026 17:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #5099 by adding
System.Diagnostics.Stopwatchto the JS/TS target, built onperformance.now()(withDate.now()as a fallback if it's ever missing).The new
Stopwatch.tskeeps the time measured before the lastStartplus the time it was started, soStopandStartaccumulate like .NET. Timestamps andElapsedTicksare in microseconds, the resolutionperformance.now()offers, soFrequencyis 1,000,000, the same as on Beam.ElapsedandGetElapsedTimego throughfromMillisecondsin the TimeSpan module, so they work with Temporal too.FrequencyandIsHighResolutionare static fields on .NET, so they're handled intryField.The tests are in
MiscTests.fsand cover the statics,StartNew,Elapsed,Start/Stop/ResetandRestart../build.sh test javascript(including the Temporal run) and./build.sh test typescriptpass, and the new tests pass on .NET as well.