Class: DiyProf::DotReporter
- Inherits:
-
Object
- Object
- DiyProf::DotReporter
- Defined in:
- lib/diy_prof/lib/diy_prof/dot_reporter.rb
Instance Method Summary collapse
-
#initialize ⇒ DotReporter
constructor
A new instance of DotReporter.
- #record(event, method_name, time) ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize ⇒ DotReporter
Returns a new instance of DotReporter.
7 8 9 10 11 12 13 14 |
# File 'lib/diy_prof/lib/diy_prof/dot_reporter.rb', line 7 def initialize # A stack for pushing/popping methods when methods get called/returned @call_stack = [] # Holds nodes @methods = {} # Holds connections among nodes @calls = {} end |
Instance Method Details
#record(event, method_name, time) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/diy_prof/lib/diy_prof/dot_reporter.rb', line 16 def record(event, method_name, time) case event when :call @call_stack << CallInfo.new(method_name, time) when :return # Return cannot be the first event in the call stack return if @call_stack.empty? method = @call_stack.pop # Set execution time of method in call info method.time = time - method.time add_method_to_call_tree(method) end end |
#result ⇒ Object
31 32 33 |
# File 'lib/diy_prof/lib/diy_prof/dot_reporter.rb', line 31 def result dot_notation end |