[dotnet] Add SystemClock singleton#15285
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
|
nvborisenko
left a comment
There was a problem hiding this comment.
Thanks, micro-optimizations are always good, even if it is nano :) I concern this approach will not work if in future we will add parameter in ctor. But I cannot image which one might be added.
|
If we add a parameter in the constructor, then users who use The only reason users may be forced to care about the For that reason, I opened #15314 👀 |
* [dotnet] Add SystemClock singleton * Fix copyright comment * Fix support UI test build
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Add
SystemClocksingletonMotivation and Context
This minimizes an allocation when using the
WebDriverWaittype, and adjacent types like components and waitsTypes of changes
Checklist
PR Type
Enhancement, Tests
Description
Introduced a singleton
SystemClock.Instanceto minimize allocations.Updated various classes to use
SystemClock.Instanceinstead of creating new instances.Refactored
FakeClocktoHandCrankClockwith improved naming and functionality.Adjusted related tests to align with the new
SystemClock.InstanceandHandCrankClock.Changes walkthrough 📝
PopupWindowFinder.cs
Use `SystemClock.Instance` in `PopupWindowFinder`dotnet/src/support/UI/PopupWindowFinder.cs
new SystemClock()withSystemClock.Instance.WebDriverWaitinitialization.SlowLoadableComponent{T}.cs
Use `SystemClock.Instance` in `SlowLoadableComponent`dotnet/src/support/UI/SlowLoadableComponent{T}.cs
new SystemClock()withSystemClock.Instance.DefaultWait{T}.cs
Use `SystemClock.Instance` in `DefaultWait`dotnet/src/webdriver/Support/DefaultWait{T}.cs
new SystemClock()withSystemClock.Instance.SystemClock.cs
Introduce singleton instance for `SystemClock`dotnet/src/webdriver/Support/SystemClock.cs
SystemClock.Instanceas a singleton instance.WebDriverWait.cs
Use `SystemClock.Instance` in `WebDriverWait`dotnet/src/webdriver/Support/WebDriverWait.cs
new SystemClock()withSystemClock.Instance.HandCrankClock.cs
Refactor `FakeClock` to `HandCrankClock`dotnet/test/support/UI/HandCrankClock.cs
FakeClocktoHandCrankClock.SlowLoadableComponentTest.cs
Update tests for `SystemClock` and `HandCrankClock`dotnet/test/support/UI/SlowLoadableComponentTest.cs
SystemClock.Instance.FakeClockwithHandCrankClock.