timed_report 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/timed_report.rb +24 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 664c1d4fdae3bbd2e849023c1e8116eb0bf4b1ac
4
- data.tar.gz: 778bd0601f86f9ec1d52e0f9506141f8fed4e9ac
3
+ metadata.gz: cc8cef0a658040b185fc68932335310823f578cc
4
+ data.tar.gz: 3a550e4bcc07e919154a84974e19159e005487d0
5
5
  SHA512:
6
- metadata.gz: 5aaba3f62b6682b60b8bc7886b030a5382b0bc6e367f2ed22526f5d081e0ca62fcc8c30067a87849853ef906d5db49b4c3b21e3166a2bcf66eb0619909488664
7
- data.tar.gz: 388aeddf395bbf591e6b72e54542ed957a93f9c3366668e03579875483db10b77ffd9c4e5a61614b17a523a27c6f32aec64d38154fe992d82613cf9bd5a04102
6
+ metadata.gz: 68c490686ebf07c884a609a9d41bc9ff3997576c3749fa97d3bbf8753204979dd996ebf32b39d18f86a5701405045edbf7f7e0eb168c643ab70ae3da31f3897b
7
+ data.tar.gz: 433efc02eba8630e9603c4654a5794bfc04a32336b166994c2445924a496f53d48b3d3dfcac33ef02a8b891d5abec0d5a1dc1595839de00670d3043704249a36
data/lib/timed_report.rb CHANGED
@@ -13,6 +13,7 @@ class TimedReport
13
13
  def initialize named = nil, enabled = true
14
14
  @enabled = enabled
15
15
  @groups = {}
16
+ @infos = []
16
17
  @intermediate_output = false
17
18
 
18
19
  @start_time = Time.now
@@ -99,10 +100,25 @@ class TimedReport
99
100
 
100
101
  if with_time
101
102
  @groups[group.to_sym][:t] += (Time.now - @step_time)
102
- @groups[group.to_sym][:n] += 1
103
103
  time_step()
104
104
  end
105
105
 
106
+ @groups[group.to_sym][:n] += 1
107
+
108
+ "❤"
109
+ end
110
+
111
+ # Adds info without time.
112
+ #
113
+ # Example:
114
+ # >> tr.info("happy: yes")
115
+ #
116
+ # Arguments:
117
+ # txt: (String)
118
+ def info txt
119
+ return nil unless @enabled
120
+ @infos.push(txt)
121
+
106
122
  "❤"
107
123
  end
108
124
 
@@ -112,11 +128,17 @@ class TimedReport
112
128
  # >> tr.finish()
113
129
  def finish
114
130
  return nil unless @enabled
131
+
115
132
  @output += "\n--------------------------" if @groups.length > 0
116
133
  @groups.each do |k,v|
117
134
  @output += "\n#{k}: %.5f (%d calls, %.5f avg.)" % [v[:t], v[:n], v[:t]/v[:n].to_f]
118
135
  end
119
- @output += "\n--------------------------"
136
+
137
+ @output += "\n---------- INFO ----------"
138
+ @infos.each do |v|
139
+ @output += "\n#{v}"
140
+ end
141
+
120
142
  @output += "\nTotal time: %.5f" % (Time.now-@start_time)
121
143
  @output += "\n=========================="
122
144
  _puke(@output)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timed_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Aizenberg