timed_report 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/disabled_report.rb +9 -0
- data/example/simple_example.rb +5 -0
- data/lib/timed_report.rb +4 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 664c1d4fdae3bbd2e849023c1e8116eb0bf4b1ac
|
4
|
+
data.tar.gz: 778bd0601f86f9ec1d52e0f9506141f8fed4e9ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aaba3f62b6682b60b8bc7886b030a5382b0bc6e367f2ed22526f5d081e0ca62fcc8c30067a87849853ef906d5db49b4c3b21e3166a2bcf66eb0619909488664
|
7
|
+
data.tar.gz: 388aeddf395bbf591e6b72e54542ed957a93f9c3366668e03579875483db10b77ffd9c4e5a61614b17a523a27c6f32aec64d38154fe992d82613cf9bd5a04102
|
data/example/simple_example.rb
CHANGED
data/lib/timed_report.rb
CHANGED
@@ -95,10 +95,11 @@ class TimedReport
|
|
95
95
|
# with_time: (Boolean)
|
96
96
|
def add_g group, with_time = true
|
97
97
|
return nil unless @enabled
|
98
|
-
@groups[group.to_sym] ||= 0
|
98
|
+
@groups[group.to_sym] ||= {t:0,n:0}
|
99
99
|
|
100
100
|
if with_time
|
101
|
-
@groups[group.to_sym] += (Time.now - @step_time)
|
101
|
+
@groups[group.to_sym][:t] += (Time.now - @step_time)
|
102
|
+
@groups[group.to_sym][:n] += 1
|
102
103
|
time_step()
|
103
104
|
end
|
104
105
|
|
@@ -113,7 +114,7 @@ class TimedReport
|
|
113
114
|
return nil unless @enabled
|
114
115
|
@output += "\n--------------------------" if @groups.length > 0
|
115
116
|
@groups.each do |k,v|
|
116
|
-
@output += "\n#{k}: %.5f" % v
|
117
|
+
@output += "\n#{k}: %.5f (%d calls, %.5f avg.)" % [v[:t], v[:n], v[:t]/v[:n].to_f]
|
117
118
|
end
|
118
119
|
@output += "\n--------------------------"
|
119
120
|
@output += "\nTotal time: %.5f" % (Time.now-@start_time)
|
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.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Aizenberg
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/timed_report.rb
|
20
20
|
- example/simple_example.rb
|
21
|
+
- example/disabled_report.rb
|
21
22
|
homepage: https://github.com/Tomtomgo/timed_report
|
22
23
|
licenses:
|
23
24
|
- MIT
|