compsci 0.3.2.4 → 0.3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/compsci.gemspec +0 -9
  4. data/lib/compsci/timer.rb +23 -39
  5. metadata +2 -114
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6988acf55d6b28d2e24ba9ac8d549287bc841d2be362293a000ffadf3e75c77
4
- data.tar.gz: b5f95b5678b3e509d5097e96727994451952cd52aa32ef0a628f383ee924af20
3
+ metadata.gz: 7e014c1fefeb5577382283a8e7f238eef921d54f34f9f6f5cded0ac72dd9def8
4
+ data.tar.gz: d8ec6042c8e94c75ed36bd0d6f9c71875534ab55abf57e14c2f9b1f6a0ecf3fe
5
5
  SHA512:
6
- metadata.gz: dade867140e16eb11f9092e87c7a464a580ae96e2f01902e155ea24f7a0247379ff355d16cd58a8a0dd2ed21a9c725a99fce649f91d3b0e0ed8a03e7d83f6b95
7
- data.tar.gz: f698945fd3d66d07a239162bfca91c5b7201f26f8353e27882139e048c6110c8134f3206a827d171873792937d55ae3f777124893a356f9c4c66aaac51d0fae1
6
+ metadata.gz: 632e293f279e44bb94d3e6e3504b24b9e0a00817f0184ba37054d05cad2616bad64613ff90a6fe5a2e29480e9d3faa155bb964e347e4009119c136a5ca4b1483
7
+ data.tar.gz: 66ed3897ac1fbb96a5f788badcbf79b9c52dbc78c528a6b500913fda328a18d76ef729864aab6fe062ce27a5616951a5308b518edd5458544f28d616862a9df3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2.4
1
+ 0.3.3.1
data/compsci.gemspec CHANGED
@@ -16,13 +16,4 @@ Gem::Specification.new do |s|
16
16
  s.files += Dir['examples/**/*.rb']
17
17
 
18
18
  s.add_dependency "matrix", "~> 0.4"
19
-
20
- s.add_development_dependency "buildar", "~> 3.0"
21
- s.add_development_dependency "minitest", "~> 5.0"
22
- s.add_development_dependency "rake", "~> 12.3" # CVE-2020-8130
23
- s.add_development_dependency "flog", "~> 0"
24
- s.add_development_dependency "flay", "~> 0"
25
- s.add_development_dependency "roodi", "~> 0"
26
- s.add_development_dependency "ruby-prof", "~> 0"
27
- s.add_development_dependency "benchmark-ips", "~> 2.0"
28
19
  end
data/lib/compsci/timer.rb CHANGED
@@ -4,24 +4,24 @@ module CompSci
4
4
  MINS_PER_HOUR = 60
5
5
  SECS_PER_HOUR = SECS_PER_MIN * MINS_PER_HOUR
6
6
 
7
- # lifted from seattlerb/minitest
7
+ # returns a float representing seconds since epoch
8
8
  if defined? Process::CLOCK_MONOTONIC
9
9
  def self.now
10
10
  Process.clock_gettime Process::CLOCK_MONOTONIC
11
11
  end
12
12
  else
13
13
  def self.now
14
- Time.now
14
+ Time.now.to_f
15
15
  end
16
16
  end
17
17
 
18
- def self.since(t)
19
- self.now - t
18
+ def self.since f
19
+ self.now - f
20
20
  end
21
21
 
22
- def self.elapsed(&work)
23
- t = self.now
24
- return yield, self.since(t)
22
+ def self.elapsed &work
23
+ f = self.now
24
+ return yield, self.since(f)
25
25
  end
26
26
 
27
27
  def self.loop_avg(count: 999, seconds: 1, &work)
@@ -34,16 +34,11 @@ module CompSci
34
34
  break if i >= count
35
35
  break if self.since(start) > seconds
36
36
  }
37
- return val, self.since(start) / i.to_f
38
- end
39
-
40
- # YYYY-MM-DD HH::MM::SS.mmm
41
- def self.timestamp(t = Time.now)
42
- t.strftime "%Y-%m-%d %H:%M:%S.%L"
37
+ return val, self.since(start) / i
43
38
  end
44
39
 
45
40
  # HH::MM::SS.mmm.uuuuuuuu
46
- def self.elapsed_display(elapsed_ms, show_us: false)
41
+ def self.elapsed_display(elapsed_ms, show_micro: false)
47
42
  elapsed_s, ms = elapsed_ms.divmod 1000
48
43
  ms_only, ms_fraction = ms.round(8).divmod 1
49
44
 
@@ -53,44 +48,33 @@ module CompSci
53
48
 
54
49
  hmsms = [[h, m, s].map { |i| i.to_s.rjust(2, '0') }.join(':'),
55
50
  ms_only.to_s.rjust(3, '0')]
56
- hmsms << (ms_fraction * 10 ** 8).round.to_s.ljust(8, '0') if show_us
51
+ hmsms << (ms_fraction * 10 ** 8).round.to_s.ljust(8, '0') if show_micro
57
52
  hmsms.join('.')
58
53
  end
59
54
 
60
- def restart(t = Timer.now)
61
- @start = t
62
- self
63
- end
64
- alias_method :initialize, :restart
65
-
66
- def timestamp(t = Time.now)
67
- self.class.timestamp t
55
+ # YYYY-MM-DD HH::MM::SS.mmm
56
+ def self.timestamp(t = Time.now)
57
+ t.strftime "%Y-%m-%d %H:%M:%S.%L"
68
58
  end
69
59
 
70
- def timestamp!(t = Time.now)
71
- puts '-' * 70, timestamp(t), '-' * 70
60
+ def restart(f = Timer.now)
61
+ @start = f
62
+ self
72
63
  end
64
+ alias_method :initialize, :restart
73
65
 
74
- def elapsed(t = Timer.now)
75
- t - @start
66
+ def elapsed(f = Timer.now)
67
+ f - @start
76
68
  end
77
69
 
78
- def elapsed_ms(t = Timer.now)
79
- elapsed(t) * 1000
70
+ def elapsed_ms(f = Timer.now)
71
+ elapsed(f) * 1000
80
72
  end
81
73
 
82
- def elapsed_display(t = Timer.now)
83
- self.class.elapsed_display(elapsed_ms(t))
74
+ def elapsed_display(f = Timer.now)
75
+ Timer.elapsed_display(elapsed_ms(f))
84
76
  end
85
77
  alias_method :to_s, :elapsed_display
86
78
  alias_method :inspect, :elapsed_display
87
-
88
- def stamp(msg = '', t = Timer.now)
89
- format("%s %s", elapsed_display(t), msg)
90
- end
91
-
92
- def stamp!(msg = '', t = Timer.now)
93
- puts stamp(msg, t)
94
- end
95
79
  end
96
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compsci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.4
4
+ version: 0.3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Hull
@@ -24,118 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.4'
27
- - !ruby/object:Gem::Dependency
28
- name: buildar
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '3.0'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '5.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '5.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '12.3'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '12.3'
69
- - !ruby/object:Gem::Dependency
70
- name: flog
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: flay
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: roodi
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: ruby-prof
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: benchmark-ips
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '2.0'
139
27
  description: Trees, Heaps, Timers, Error fitting, etc
140
28
  email:
141
29
  executables: []
@@ -201,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
89
  - !ruby/object:Gem::Version
202
90
  version: '0'
203
91
  requirements: []
204
- rubygems_version: 3.2.26
92
+ rubygems_version: 3.4.4
205
93
  signing_key:
206
94
  specification_version: 4
207
95
  summary: Toy implementations for some basic computer science problems