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.
- checksums.yaml +4 -4
- data/lib/timed_report.rb +24 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc8cef0a658040b185fc68932335310823f578cc
|
4
|
+
data.tar.gz: 3a550e4bcc07e919154a84974e19159e005487d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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)
|