Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Add Measure::as_duration() #25942

Merged
merged 1 commit into from
Jun 14, 2022

Conversation

brooksprumo
Copy link
Contributor

Problem

Measure does not have a method to return its duration as a Duration. I've found myself wanting this method to use when interfacing with other code that takes in a Duration.

Summary of Changes

Add as_duration() to Measure.

@brooksprumo brooksprumo marked this pull request as ready for review June 13, 2022 18:29
@brooksprumo brooksprumo requested a review from apfitzge June 13, 2022 18:29
Copy link
Contributor

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Though, it seems slightly strange we have a duration from elapsed and then rebuild it from the ns. But not sure there's any benefit changing the measure to store Duration instead.

@brooksprumo
Copy link
Contributor Author

Though, it seems slightly strange we have a duration from elapsed and then rebuild it from the ns. But not sure there's any benefit changing the measure to store Duration instead.

Yep, agreed. I figured this PR didn't need to address that underlying issue. A Duration type is 12 bytes, versus 8 B with just a u64 currently. I can't imagine that this would be a big performance drain, so a future PR could likely change the duration field to an actual Duration and simplify the impl.

@brooksprumo brooksprumo added the automerge Merge this Pull Request automatically once CI passes label Jun 13, 2022
@mergify mergify bot removed the automerge Merge this Pull Request automatically once CI passes label Jun 13, 2022
@mergify
Copy link
Contributor

mergify bot commented Jun 13, 2022

automerge label removed due to a CI failure

@codecov
Copy link

codecov bot commented Jun 14, 2022

Codecov Report

Merging #25942 (68b5142) into master (8caced6) will decrease coverage by 0.1%.
The diff coverage is 77.6%.

@@            Coverage Diff            @@
##           master   #25942     +/-   ##
=========================================
- Coverage    82.1%    82.0%   -0.2%     
=========================================
  Files         628      631      +3     
  Lines      171471   172926   +1455     
=========================================
+ Hits       140878   141874    +996     
- Misses      30593    31052    +459     

@brooksprumo brooksprumo merged commit 85e3833 into solana-labs:master Jun 14, 2022
@brooksprumo brooksprumo deleted the measure/as_duration branch June 14, 2022 13:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants