gestalt 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/gestalt.gemspec +2 -2
- data/lib/gestalt.rb +33 -11
- metadata +3 -3
data/gestalt.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'gestalt'
|
16
|
-
s.version = '0.0.
|
17
|
-
s.date = '2010-
|
16
|
+
s.version = '0.0.5'
|
17
|
+
s.date = '2010-05-01'
|
18
18
|
s.rubyforge_project = 'gestalt'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/gestalt.rb
CHANGED
@@ -5,13 +5,30 @@ require 'formatador'
|
|
5
5
|
|
6
6
|
class Gestalt
|
7
7
|
|
8
|
-
VERSION = '0.0.
|
8
|
+
VERSION = '0.0.5'
|
9
9
|
|
10
10
|
attr_accessor :calls
|
11
11
|
|
12
|
-
def initialize(
|
12
|
+
def initialize(options = {})
|
13
|
+
options = {
|
14
|
+
'call' => true,
|
15
|
+
'c-call' => false,
|
16
|
+
:formatador => Formatador.new
|
17
|
+
}.merge!(options)
|
18
|
+
|
19
|
+
@traceable_calls = []
|
20
|
+
@traceable_returns = []
|
21
|
+
if options['call']
|
22
|
+
@traceable_calls << 'call'
|
23
|
+
@traceable_returns << 'return'
|
24
|
+
end
|
25
|
+
if options ['c-call']
|
26
|
+
@traceable_calls << 'c-call'
|
27
|
+
@traceable_returns << 'c-return'
|
28
|
+
end
|
29
|
+
|
13
30
|
@calls = []
|
14
|
-
@formatador = formatador
|
31
|
+
@formatador = options[:formatador]
|
15
32
|
@stack = []
|
16
33
|
@totals = {}
|
17
34
|
end
|
@@ -57,8 +74,7 @@ class Gestalt
|
|
57
74
|
Kernel.set_trace_func(
|
58
75
|
lambda do |event, file, line, id, binding, classname|
|
59
76
|
case event
|
60
|
-
when
|
61
|
-
# p "call #{classname}##{id}"
|
77
|
+
when *@traceable_calls
|
62
78
|
call = Gestalt::Call.new(
|
63
79
|
:action => "#{classname}##{id}",
|
64
80
|
:location => "#{file}:#{line}"
|
@@ -67,8 +83,7 @@ class Gestalt
|
|
67
83
|
@stack.last.children.push(call)
|
68
84
|
end
|
69
85
|
@stack.push(call)
|
70
|
-
when
|
71
|
-
# p "return #{classname}##{id}"
|
86
|
+
when *@traceable_returns
|
72
87
|
unless @stack.empty? # we get one of these when we set the trace_func
|
73
88
|
call = @stack.pop
|
74
89
|
call.finish
|
@@ -94,14 +109,14 @@ class Gestalt
|
|
94
109
|
end
|
95
110
|
end
|
96
111
|
|
97
|
-
def self.profile(
|
98
|
-
gestalt = new(
|
112
|
+
def self.profile(options = {}, &block)
|
113
|
+
gestalt = new(options)
|
99
114
|
gestalt.run(&block)
|
100
115
|
gestalt.display_profile
|
101
116
|
end
|
102
117
|
|
103
|
-
def self.trace(
|
104
|
-
gestalt = new(
|
118
|
+
def self.trace(options = {}, &block)
|
119
|
+
gestalt = new(options)
|
105
120
|
gestalt.run(&block)
|
106
121
|
gestalt.display_calls
|
107
122
|
end
|
@@ -151,6 +166,13 @@ if __FILE__ == $0
|
|
151
166
|
|
152
167
|
end
|
153
168
|
|
169
|
+
Gestalt.trace('c-call' => true) do
|
170
|
+
|
171
|
+
slow = Slow.new
|
172
|
+
slow.slowing
|
173
|
+
|
174
|
+
end
|
175
|
+
|
154
176
|
Gestalt.profile do
|
155
177
|
|
156
178
|
slow = Slow.new
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-01 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|