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

Add multipliers for sub-second timing #13

Merged
merged 2 commits into from
Dec 15, 2023
Merged

Conversation

stevegrunwell
Copy link
Owner

I reviewed a PR at work today that included logic that took some number of seconds as an integer, then had to compute the number of milliseconds in order to interact with a Prometheus service. I realized that even if we were using this library, there would still be a $seconds * 1000 expression somewhere, which means people trying to do [albeit simple] math.

This PR adds four "multipliers", representing the most common submultiples of second in the International System of Units:

Unit Symbol Constant Size
Millisecond ms MILLISECONDS_PER_SECOND One thousandth (1/1000) of a second
Microsecond µs MICROSECONDS_PER_SECOND One millionth (1/1000000) of a second
Nanosecond ns NANOSECONDS_PER_SECOND One billionth (1/1000000000) of a second
Picosecond ps PICOSECONDS_PER_SECOND One trillionth (1/1000000000000) of a second

It's unlikely that nanoseconds nor picoseconds will really get much use, but microseconds are useful when dealing with high-resolution time, and milliseconds are popular for measuring performance, microcaching, and more.

@stevegrunwell stevegrunwell merged commit 302a096 into develop Dec 15, 2023
3 checks passed
@stevegrunwell stevegrunwell deleted the feature/multipliers branch December 15, 2023 04:25
@stevegrunwell stevegrunwell mentioned this pull request Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant