Skip to content

Rework OpTimer and NanoTime #4777

@DomGarguilo

Description

@DomGarguilo

This ticket is based on this discussion. Below are some points to summarize what is being suggested to be done here:

  • Merge OpTimer into NanoTime since they have a large overlap in functionality.
  • Rename NanoTime to something else since it doesn't expose nanosecond units at all. Some suggestions are "Stopwatch," "ElapsedTime," or "Timer."
  • Add a hasElapsed(Duration) method to make comparisons more efficient and more readable.
  • Add a reset() method to make it easier to reuse the object.

Since OpTimer is in the 2.1 branch and only NanoTime is in main and later, it would be beneficial to standardize the usage across these branches. Specifically, after the new Timer class is created, we should:

  1. Identify places in the 2.1 branch where NanoTime would be beneficial but currently can't be used because it doesn't exist in that branch.
  2. Replace OpTimer with the new Timer class in the 2.1 branch.
  3. Ensure the new Timer class is used consistently across all branches.

The replacing and consistency steps will be handled in a separate PR after the initial changes are completed.

Metadata

Metadata

Assignees

Labels

enhancementThis issue describes a new feature, improvement, or optimization.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions