monotime 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +0 -40
- data/lib/monotime.rb +0 -41
- data/lib/monotime/version.rb +1 -1
- data/monotime.gemspec +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09910c8dfa9bdc7777e55f6eb606b49f8c6ca23d563e09ae8e5109b116b7781f'
|
4
|
+
data.tar.gz: 5db6e948d04836e8523cbeaf92e4f599c5ed9238055f5fb79d94dfcab1969a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '087abc138dd09dd52d5b3adb5bc6ad276e0ad5936e9aa381ce43dbf12a62dfc1f65449b0d36454a78527842d70ca3ab7752d94ffea7cecbf9f05b85917c11d95'
|
7
|
+
data.tar.gz: e2b45aaef34322a3ef71fdf7317af1a363a5e7b1f3e86d6b8c65df8b444dcfa03d210a11ee7adb051cd22794776b02e984781fb69db5183fcd76659683dbee1b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.6.1] - 2018-10-27
|
4
|
+
### Fixed
|
5
|
+
- Build gem from a clean git checkout, not my local development directory.
|
6
|
+
No functional changes.
|
7
|
+
|
3
8
|
## [0.6.0] - 2018-10-26
|
4
9
|
### Added
|
5
10
|
- This `CHANGELOG.md` by request of [@celsworth].
|
@@ -75,4 +80,5 @@
|
|
75
80
|
[0.4.0]: https://github.com/Freaky/monotime/commits/v0.4.0
|
76
81
|
[0.5.0]: https://github.com/Freaky/monotime/commits/v0.5.0
|
77
82
|
[0.6.0]: https://github.com/Freaky/monotime/commits/v0.6.0
|
83
|
+
[0.6.1]: https://github.com/Freaky/monotime/commits/v0.6.1
|
78
84
|
[@celsworth]: https://github.com/celsworth
|
data/README.md
CHANGED
@@ -5,46 +5,6 @@
|
|
5
5
|
|
6
6
|
A sensible interface to Ruby's monotonic clock, inspired by Rust.
|
7
7
|
|
8
|
-
## Synopsis
|
9
|
-
|
10
|
-
Monotonic clocks are what you use to measure elapsed time: unlike the system
|
11
|
-
clock they're guaranteed to always move forward.
|
12
|
-
|
13
|
-
This is perfectly valid behaviour:
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
start = Time.new
|
17
|
-
do_something
|
18
|
-
elapsed = Time.new - start # -3599.421234
|
19
|
-
```
|
20
|
-
|
21
|
-
Monotonic clocks never do this. Typically you'd avoid this by using
|
22
|
-
`Process#clock_gettime` with the appropriate arguments:
|
23
|
-
|
24
|
-
```ruby
|
25
|
-
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
26
|
-
do_something
|
27
|
-
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
28
|
-
```
|
29
|
-
|
30
|
-
But this isn't very Rubyish - it's a thin veneer over the POSIX C API.
|
31
|
-
|
32
|
-
`monotime` offers this alternative, similar to that found in Rust:
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
include Monotime
|
36
|
-
|
37
|
-
start = Instant.now
|
38
|
-
do_something
|
39
|
-
elapsed = start.elapsed
|
40
|
-
|
41
|
-
# or
|
42
|
-
elapsed = Duration.measure { do_something }
|
43
|
-
```
|
44
|
-
|
45
|
-
Where `elapsed` is a dedicated type for measuring durations, with conversion
|
46
|
-
and formatting methods.
|
47
|
-
|
48
8
|
## Installation
|
49
9
|
|
50
10
|
Add this line to your application's Gemfile:
|
data/lib/monotime.rb
CHANGED
@@ -465,46 +465,5 @@ module Monotime
|
|
465
465
|
format("%#.#{precision}f", to_nanos / div).sub(/\.?0*\z/, '') << unit
|
466
466
|
end
|
467
467
|
end
|
468
|
-
|
469
|
-
# def to_s_bigdecimal(precision = 9)
|
470
|
-
# require 'bigdecimal'
|
471
|
-
# precision = Integer(precision).abs
|
472
|
-
# div, unit = DIVISORS.find { |d, _| to_nanos.abs >= d }
|
473
|
-
|
474
|
-
# if div.zero?
|
475
|
-
# format('%d%s', to_nanos, unit)
|
476
|
-
# else
|
477
|
-
# num = (BigDecimal(to_nanos) / div.to_i)
|
478
|
-
# .round(precision, :banker).to_s('F').sub(/\.?0*$/, '')
|
479
|
-
# format('%s%s', num, unit)
|
480
|
-
# end
|
481
|
-
# end
|
482
|
-
|
483
|
-
# def to_s_divmod(precision = 9)
|
484
|
-
# precision = Integer(precision).abs
|
485
|
-
|
486
|
-
# ns = to_nanos.abs
|
487
|
-
# div, unit = DIVISORS.find { |d, _| ns >= d }
|
488
|
-
|
489
|
-
# return format('%dns', to_nanos) if div.zero?
|
490
|
-
|
491
|
-
# whole, frac = to_nanos.divmod(div.to_i)
|
492
|
-
|
493
|
-
# if precision.zero? || frac.zero?
|
494
|
-
# whole += 1 if frac > div / 2
|
495
|
-
# return format('%d%s', whole, unit)
|
496
|
-
# end
|
497
|
-
|
498
|
-
# # XXX: still need to round: Duration.from_nanos(99999999999).to_s_divmod 7 # => 99.1s
|
499
|
-
# p frac
|
500
|
-
# frac = ((frac / div.to_f) * (10 ** precision)).round
|
501
|
-
# if frac.to_s =~ /\A10*\z/ # erm...
|
502
|
-
# whole += 1
|
503
|
-
# frac = 0
|
504
|
-
# end
|
505
|
-
# num = format('%d.%d', whole, frac)
|
506
|
-
# num.sub!(/\.?0*\z/, '') if precision.nonzero?
|
507
|
-
# num << unit
|
508
|
-
# end
|
509
468
|
end
|
510
469
|
end
|
data/lib/monotime/version.rb
CHANGED
data/monotime.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monotime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Hurst
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: simplecov
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
description:
|
70
56
|
email:
|
71
57
|
- tom@hur.st
|