ztk 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbbba71c8a07c8110549bfcee7445288c8ed3172
4
- data.tar.gz: 8c725fa5f1de381ce76f668e52c7735d87a1429f
3
+ metadata.gz: 445fbcb89579b4066b00b22ea2c5a2c1663be79c
4
+ data.tar.gz: 9f53bd0cc361e7ac08c430554cfdb97e5848885e
5
5
  SHA512:
6
- metadata.gz: 4ebd5505c5e8607536a054788d545432011aae08f3243cf9614e9c87c17567009784f014d6dbbc0141e0f117dab5ea3fa0b88dc93f0ed6163a5b280cb81d4de1
7
- data.tar.gz: 96e9aa8493a4336e5723df3f3f6aed28856108cef55f16c76208cea07cff583895e92ed122d3125c3bc50276806678a957c3250a03747516b301d3507c71ce6f
6
+ metadata.gz: 1bfd737eff5c8c0b51346e8bb928483735e733d4bb3042605464fbe7d16bc3eef7fc41fc95962263eda49f67751de225a546d133af85f3ccdc99d70f8740c2a0
7
+ data.tar.gz: 0a447e77357723be1652721c88d0319663d40ba5688e252ede7d7a18dc61f6ef13f9b41957729e33a4fabf32bedb694cde51ba5968a00bfacf62995970aa1799
@@ -35,15 +35,21 @@ module ZTK
35
35
 
36
36
  @@start_time ||= Time.now.utc
37
37
 
38
- result = nil
39
- timer = Timer.new(method_name, @@timer_stack.last)
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
- result = yield
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
- results = Array.new
61
-
62
- report_timers(options)
63
- options.ui.stdout.puts
64
- results << report_timer_totals(options)
65
- options.ui.stdout.puts
66
- results << report_totals(options)
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
@@ -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,
@@ -54,6 +54,10 @@ module ZTK
54
54
  result
55
55
  end
56
56
 
57
+ def count
58
+ @@timers.count
59
+ end
60
+
57
61
  def benchmark_total
58
62
  @@benchmark_total ||= @@timers.map(&:benchmark).reduce(&:+)
59
63
  @@benchmark_total
data/lib/ztk/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "2.4.0"
4
+ VERSION = "2.4.1"
5
5
 
6
6
  end
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2014-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport