Skip to content

Commit

Permalink
Prepare for 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Freaky committed Sep 17, 2023
1 parent ef5d224 commit 2248eee
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 62 deletions.
157 changes: 106 additions & 51 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,153 @@
# Changelog

## 0.7.1 - 2021-10-22
## [0.8.0] - 2023-09-17

### Added

- Default precision for `Duration#to_s` can be set using
`Duration.default_to_s_precision=`
- Default sleep function can be set using `Duration.sleep_function=`
- `Duration::ZERO` and `Duration.zero` for an easy, memory-efficient
zero-duration singleton.
- `Instant.clock_id` and `Instant.clock_id=` to control the default clock
source
- `Instant.clock_getres` to get the minimum supported `Duration` from the
selected clock source
- `Instant.monotonic_function=` to completely replace the default monotonic
function

### Changed

- The default clock source now chooses from a selection of options depending on
which have the highest resolution and most suitable behaviour on a given
platform, including avoiding NTP frequency skew and counting time spent in
system suspend.

### Removed

- Testing under Ruby 2.5 and 2.6.

## [0.7.1] - 2021-10-22

### Added
- `simplecov` introduced to test suite.
- `monotime/include.rb` to auto-include types globally.

- `simplecov` introduced to test suite.
- `monotime/include.rb` to auto-include types globally.

### Changed
- All `Instant` and `Duration` instances are now frozen.
- Migrate from Travis CI to Github Actions
- Update development dependency on `rake`.

- All `Instant` and `Duration` instances are now frozen.
- Migrate from Travis CI to Github Actions
- Update development dependency on `rake`.

## [0.7.0] - 2019-04-24

### Added
- `Duration.with_measure`, which yields and returns an array containing its
evaluated return value and its `Duration`.

- `Duration.with_measure`, which yields and returns an array containing its
evaluated return value and its `Duration`.

### Changed
- Break `Duration` and `Instant` into their own files.
- Rename `Monotime::VERSION` to `Monotime::MONOTIME_VERSION` to reduce
potential for collision if the module is included.
- Update to bundler 2.0.
- Rework README.md. Includes fix for [issue #1] (added a "See Also" section).

- Break `Duration` and `Instant` into their own files.
- Rename `Monotime::VERSION` to `Monotime::MONOTIME_VERSION` to reduce
potential for collision if the module is included.
- Update to bundler 2.0.
- Rework README.md. Includes fix for [issue #1] (added a "See Also" section).

## [0.6.1] - 2018-10-26

### Fixed
- Build gem from a clean git checkout, not my local development directory.
No functional changes.

- Build gem from a clean git checkout, not my local development directory.
No functional changes.

## [0.6.0] - 2018-10-26

### Added
- This `CHANGELOG.md` by request of [@celsworth].
- Aliases for `Duration.from_*` and `Duration#to_*` without the prefix. e.g.
`Duration.from_secs(42).to_secs == 42` can now be written as
`Duration.secs(42).secs == 42`.
- `Duration#nonzero?`.
- `Instant#in_past?` and `Instant#in_future?`.

- This `CHANGELOG.md` by request of [@celsworth].
- Aliases for `Duration.from_*` and `Duration#to_*` without the prefix. e.g.
`Duration.from_secs(42).to_secs == 42` can now be written as
`Duration.secs(42).secs == 42`.
- `Duration#nonzero?`.
- `Instant#in_past?` and `Instant#in_future?`.

## [0.5.0] - 2018-10-13

### Added
- `Duration#abs` to make a `Duration` positive.
- `Duration#-@` to invert the sign of a `Duration`.
- `Duration#positive?`
- `Duration#negative?`
- `Duration#zero?`

- `Duration#abs` to make a `Duration` positive.
- `Duration#-@` to invert the sign of a `Duration`.
- `Duration#positive?`
- `Duration#negative?`
- `Duration#zero?`

### Changed
- `Instant#sleep` with no argument now sleeps until the `Instant`.
- `Duration.from_*` no longer coerce their argument to `Float`.
- `Duration#==` checks value via `#to_nanos`, not type.
- `Duration#eql?` checks value and type.
- `Duration#<=>` compares value via `#to_nanos`.

- `Instant#sleep` with no argument now sleeps until the `Instant`.
- `Duration.from_*` no longer coerce their argument to `Float`.
- `Duration#==` checks value via `#to_nanos`, not type.
- `Duration#eql?` checks value and type.
- `Duration#<=>` compares value via `#to_nanos`.

## [0.4.0] - 2018-10-09

### Added
- `Instant#sleep` - sleep to a given `Duration` past an `Instant`.
- `Instant#sleep_secs` and `Instant#sleep_millis` convenience methods.
- `Duration#sleep` - sleep for the `Duration`.
- `Duration#*` - multiply a `Duration` by a number.
- `Duration#/` - divide a `Duration` by a number.

- `Instant#sleep` - sleep to a given `Duration` past an `Instant`.
- `Instant#sleep_secs` and `Instant#sleep_millis` convenience methods.
- `Duration#sleep` - sleep for the `Duration`.
- `Duration#*` - multiply a `Duration` by a number.
- `Duration#/` - divide a `Duration` by a number.

### Changed
- More `#to_nanos` `Duration` duck-typing.

More `#to_nanos` `Duration` duck-typing.

## [0.3.0] - 2018-10-04

### Added
- `#to_nanos` is now used to duck-type `Duration` everywhere.

- `#to_nanos` is now used to duck-type `Duration` everywhere.

### Changed
- Make `<=>` return nil on invalid types, rather than raising a `TypeError`.

- Make `<=>` return nil on invalid types, rather than raising a `TypeError`.

### Removed
- Dependency on `dry-equalizer`.

- Dependency on `dry-equalizer`.

## [0.2.0] - 2018-10-03

### Added
- `Instant#to_s` as an alias for `#elapsed.to_s`
- `Duration#to_nanos`, with some limited duck-typing.

- `Instant#to_s` as an alias for `#elapsed.to_s`
- `Duration#to_nanos`, with some limited duck-typing.

### Changed
- Switch to microseconds internally.
- `Duration#to_{secs,millis,micros}` now return a `Float`.
- `Instant#ns` is now `protected`.

- Switch to microseconds internally.
- `Duration#to_{secs,millis,micros}` now return a `Float`.
- `Instant#ns` is now `protected`.

### Fixed
- `Duration#to_s` zero-stripping with precision=0.
- `Instant#-` argument ordering with other `Instant`.
- `Duration#to_micros` returns microseconds, not picoseconds.

- `Duration#to_s` zero-stripping with precision=0.
- `Instant#-` argument ordering with other `Instant`.
- `Duration#to_micros` returns microseconds, not picoseconds.

### Removed
- `Instant` and `Duration` maths methods no longer support passing an `Integer`
number of nanoseconds.

- `Instant` and `Duration` maths methods no longer support passing an `Integer`
number of nanoseconds.

## [0.1.0] - 2018-10-02

### Added
- Initial release

- Initial release

[0.1.0]: https://github.com/Freaky/monotime/commits/v0.1.0
[0.2.0]: https://github.com/Freaky/monotime/commits/v0.2.0
Expand All @@ -104,5 +157,7 @@
[0.6.0]: https://github.com/Freaky/monotime/commits/v0.6.0
[0.6.1]: https://github.com/Freaky/monotime/commits/v0.6.1
[0.7.0]: https://github.com/Freaky/monotime/commits/v0.7.0
[0.7.1]: https://github.com/Freaky/monotime/commits/v0.7.0
[0.8.0]: https://github.com/Freaky/monotime/commits/v0.7.0
[issue #1]: https://github.com/Freaky/monotime/issues/1
[@celsworth]: https://github.com/celsworth
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[![Gem Version](https://badge.fury.io/rb/monotime.svg)](https://badge.fury.io/rb/monotime)
![Build Status](https://github.com/Freaky/monotime/actions/workflows/ci.yml/badge.svg)
[![Inline docs](http://inch-ci.org/github/Freaky/monotime.svg?branch=master)](http://inch-ci.org/github/Freaky/monotime)
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/monotime)

# Monotime

A sensible interface to Ruby's monotonic clock, inspired by Rust.

[![Gem Version](https://badge.fury.io/rb/monotime.svg)](https://badge.fury.io/rb/monotime)
[![Build Status](https://github.com/Freaky/monotime/actions/workflows/ci.yml/badge.svg)](https://github.com/Freaky/monotime/actions)
[![Inline docs](http://inch-ci.org/github/Freaky/monotime.svg?branch=master)](http://inch-ci.org/github/Freaky/monotime)
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/monotime)

## Installation

Add this line to your application's Gemfile:
Expand Down Expand Up @@ -159,7 +160,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Freaky/monotime.
Bug reports and pull requests are welcome on GitHub at <https://github.com/Freaky/monotime>.

## License

Expand All @@ -169,13 +170,19 @@ The gem is available as open source under the terms of the [MIT License](https:/

### Core Ruby

For a zero-dependency alternative, see
For a zero-dependency alternative upon which `monotime` is based, see
[`Process.clock_gettime`](https://ruby-doc.org/core-2.6.3/Process.html#method-c-clock_gettime).
`monotime` currently only uses `Process::CLOCK_MONOTONIC`, but others may offer higher precision
depending on platform.

`Process::CLOCK_MONOTONIC` is a safe default, but other options may offer better
behaviour in face of NTP frequency skew or suspend/resume and should be evaluated
carefully.

### Other Gems

[hitimes](https://rubygems.org/gems/hitimes) is a popular and mature alternative
which also includes a variety of features for gathering statistics about
measurements, and may offer higher precision on some platforms.
measurements.

[concurrent-ruby](https://rubygems.org/gems/concurrent-ruby) includes
`Concurrent.monotonic_time`, which is at the time of writing a trivial proxy to
the aforementioned `Process::clock_gettime` with `Process::CLOCK_MONOTONIC`.
4 changes: 2 additions & 2 deletions lib/monotime/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Monotime
# Try to avoid blatting existing VERSION constants when we're included.
MONOTIME_VERSION = '0.7.1'
# Version of the `monotime` gem
MONOTIME_VERSION = '0.8.0'
end

0 comments on commit 2248eee

Please sign in to comment.