sus 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e158f43458d5d3c2bc5835ab0493b22d4c09c8f2c733cb8e42095ed5b7566a0
4
- data.tar.gz: 4ef00aa6fe64b16271a8d219ee8f20bab23064ab5546e64885f040bf9cc5a180
3
+ metadata.gz: f878b94ac4b8236fdb411866336061b34cca3c59a9573e4cb0ef238d545ffe3d
4
+ data.tar.gz: c61aaee1228f6ab7796811ee739de195a5b59cf1a014f304d08f3d64488c94ba
5
5
  SHA512:
6
- metadata.gz: 88ec5c608a1e0131702bb1c2a530b0811072a9e47df858f46635dc94fade1855cad48e6005514329de5994a2c30882cb97a8b62b73787fad9bd30ec596d24937
7
- data.tar.gz: 1e7551d9b5007a6158bd0b690743b1ab0c448fe0ed507692f0ba14fa1697ba61b49af781ce1b70a24a2c839f72ddfcc5a7de7bd46158f723a97044c1c1a0e6f5
6
+ metadata.gz: 181ee960cee58bf710d7de09a6f83f72a71f01d25716d18dd386562bf2984e14f690cfa1561b298d36bc068d06676481979866f48ee2a2716866e725a9d3c07f
7
+ data.tar.gz: 206fa66d07315578142b07b3802a66af629668502a2745dbf4a3f60cbebf4c8d8cc8c2edd4011397a22b7d039c753874409fe576d42890745629d4d5ac57a906
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sus/clock.rb CHANGED
@@ -15,23 +15,33 @@ module Sus
15
15
  @duration = duration
16
16
  end
17
17
 
18
- attr :duration
18
+ def duration
19
+ if @start_time
20
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
21
+ @duration += now - @start_time
22
+ @start_time = now
23
+ end
24
+
25
+ return @duration
26
+ end
19
27
 
20
28
  def <=>(other)
21
- @duration <=> other.to_f
29
+ duration <=> other.to_f
22
30
  end
23
31
 
24
32
  def to_f
25
- @duration
33
+ duration
26
34
  end
27
35
 
28
36
  def to_s
29
- if @duration < 0.001
30
- "#{(@duration * 1_000_000).round(1)}µs"
31
- elsif @duration < 1.0
32
- "#{(@duration * 1_000).round(1)}ms"
37
+ duration = self.duration
38
+
39
+ if duration < 0.001
40
+ "#{(duration * 1_000_000).round(1)}µs"
41
+ elsif duration < 1.0
42
+ "#{(duration * 1_000).round(1)}ms"
33
43
  else
34
- "#{@duration.round(1)}s"
44
+ "#{duration.round(1)}s"
35
45
  end
36
46
  end
37
47
 
@@ -41,11 +51,12 @@ module Sus
41
51
 
42
52
  def stop!
43
53
  if @start_time
44
- @duration += Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start_time
54
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
55
+ @duration += now - @start_time
45
56
  @start_time = nil
46
57
  end
47
58
 
48
- return @duration
59
+ return duration
49
60
  end
50
61
  end
51
62
  end
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.11.1"
7
+ VERSION = "0.11.2"
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file