ztk 2.4.0 → 2.4.1
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/ztk/profiler/core.rb +19 -10
- data/lib/ztk/profiler/private.rb +6 -0
- data/lib/ztk/profiler/timer/class_methods.rb +4 -0
- data/lib/ztk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 445fbcb89579b4066b00b22ea2c5a2c1663be79c
|
4
|
+
data.tar.gz: 9f53bd0cc361e7ac08c430554cfdb97e5848885e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bfd737eff5c8c0b51346e8bb928483735e733d4bb3042605464fbe7d16bc3eef7fc41fc95962263eda49f67751de225a546d133af85f3ccdc99d70f8740c2a0
|
7
|
+
data.tar.gz: 0a447e77357723be1652721c88d0319663d40ba5688e252ede7d7a18dc61f6ef13f9b41957729e33a4fabf32bedb694cde51ba5968a00bfacf62995970aa1799
|
data/lib/ztk/profiler/core.rb
CHANGED
@@ -35,15 +35,21 @@ module ZTK
|
|
35
35
|
|
36
36
|
@@start_time ||= Time.now.utc
|
37
37
|
|
38
|
-
result
|
39
|
-
|
38
|
+
result = nil
|
39
|
+
exception = nil
|
40
|
+
timer = Timer.new(method_name, @@timer_stack.last)
|
40
41
|
|
41
42
|
@@timer_stack.push(timer)
|
42
43
|
timer.benchmark = ::Benchmark.realtime do
|
43
|
-
|
44
|
+
begin
|
45
|
+
result = yield
|
46
|
+
rescue Exception => exception
|
47
|
+
end
|
44
48
|
end
|
45
49
|
@@timer_stack.pop
|
46
50
|
|
51
|
+
exception.nil? or raise exception
|
52
|
+
|
47
53
|
result
|
48
54
|
end
|
49
55
|
|
@@ -53,17 +59,20 @@ module ZTK
|
|
53
59
|
end
|
54
60
|
|
55
61
|
def report(options={})
|
62
|
+
results = Array.new
|
56
63
|
options = Base.build_config({}, options)
|
57
64
|
|
58
65
|
stop
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
if (Timer.count > 0)
|
68
|
+
report_timers(options) and options.ui.stdout.puts
|
69
|
+
results << report_timer_totals(options)
|
70
|
+
results.last and options.ui.stdout.puts
|
71
|
+
results << report_totals(options)
|
72
|
+
else
|
73
|
+
options.ui.stderr.puts("Nothing was profiled!")
|
74
|
+
results = [ nil, nil ]
|
75
|
+
end
|
67
76
|
|
68
77
|
results
|
69
78
|
end
|
data/lib/ztk/profiler/private.rb
CHANGED
@@ -5,6 +5,8 @@ module ZTK
|
|
5
5
|
module Private
|
6
6
|
|
7
7
|
def report_timers(options={}, parent=nil, depth=0)
|
8
|
+
return false if (Timer.count == 0)
|
9
|
+
|
8
10
|
child_timers = Timer.timers_by_parent[parent]
|
9
11
|
child_timers.each do |timer|
|
10
12
|
prefix = (' |' * (depth))
|
@@ -18,6 +20,8 @@ module ZTK
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def report_timer_totals(options={})
|
23
|
+
return false if (Timer.count == 0)
|
24
|
+
|
21
25
|
result = Hash.new
|
22
26
|
timer_names = Timer.timers_by_name.keys.compact
|
23
27
|
timer_names_camelize = timer_names.map(&:to_s).map(&:camelize)
|
@@ -32,6 +36,8 @@ module ZTK
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def report_totals(options={})
|
39
|
+
return false if (Timer.count == 0)
|
40
|
+
|
35
41
|
times = {
|
36
42
|
'Nested Time' => Timer.benchmark_nested_total,
|
37
43
|
'Actual Time' => Profiler.total_time,
|
data/lib/ztk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Patten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|