Class: Benchin::Wrap::Report::Node Private
- Inherits:
-
Object
- Object
- Benchin::Wrap::Report::Node
- Defined in:
- lib/benchin/wrap/report/node.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Defined Under Namespace
Classes: Virtual
Instance Attribute Summary collapse
- #calls ⇒ Object readonly private
- #name ⇒ Object readonly private
- #nested ⇒ Object readonly private
- #total_seconds ⇒ Object readonly private
Instance Method Summary collapse
- #add_call(seconds) ⇒ Object private
- #child_seconds ⇒ Object private
-
#initialize(name) ⇒ Node
constructor
private
A new instance of Node.
- #self_seconds ⇒ Object private
- #to_h ⇒ Object private
Constructor Details
#initialize(name) ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Node.
11 12 13 14 15 16 17 |
# File 'lib/benchin/wrap/report/node.rb', line 11 def initialize(name) @name = name @calls = 0 @total_seconds = 0.0 @nested = {} end |
Instance Attribute Details
#calls ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'lib/benchin/wrap/report/node.rb', line 7 def calls @calls end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/benchin/wrap/report/node.rb', line 6 def name @name end |
#nested ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/benchin/wrap/report/node.rb', line 9 def nested @nested end |
#total_seconds ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/benchin/wrap/report/node.rb', line 8 def total_seconds @total_seconds end |
Instance Method Details
#add_call(seconds) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 |
# File 'lib/benchin/wrap/report/node.rb', line 19 def add_call(seconds) @child_seconds = nil @calls += 1 @total_seconds += seconds end |
#child_seconds ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 |
# File 'lib/benchin/wrap/report/node.rb', line 40 def child_seconds child_nodes = nested.values @child_seconds ||= child_nodes.map(&:total_seconds).sum.to_f end |
#self_seconds ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/benchin/wrap/report/node.rb', line 36 def self_seconds total_seconds - child_seconds end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/benchin/wrap/report/node.rb', line 25 def to_h { name: name, calls: calls, total_seconds: total_seconds, self_seconds: self_seconds, child_seconds: child_seconds, nested: nested.values.map(&:to_h) } end |