Class: Silhouette::ProfileNode
- Inherits:
-
Object
- Object
- Silhouette::ProfileNode
- Defined in:
- lib/silhouette/processor.rb
Instance Attribute Summary collapse
-
#callers ⇒ Object
Returns the value of attribute callers.
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#children ⇒ Object
Returns the value of attribute children.
-
#key ⇒ Object
(also: #method)
readonly
Returns the value of attribute key.
-
#self_sec ⇒ Object
Returns the value of attribute self_sec.
-
#total_sec ⇒ Object
Returns the value of attribute total_sec.
Instance Method Summary collapse
- #add_cost(cost, last) ⇒ Object
- #inc_call! ⇒ Object
-
#initialize(key, children = []) ⇒ ProfileNode
constructor
A new instance of ProfileNode.
- #percentage(total) ⇒ Object
- #self_ms_per_call ⇒ Object
- #total_ms_per_call ⇒ Object
Constructor Details
#initialize(key, children = []) ⇒ ProfileNode
Returns a new instance of ProfileNode.
59 60 61 62 63 64 65 66 |
# File 'lib/silhouette/processor.rb', line 59 def initialize(key, children=[]) @key = key @total_sec = 0.0 @self_sec = 0.0 @calls = 0 @callers = [] @children = children end |
Instance Attribute Details
#callers ⇒ Object
Returns the value of attribute callers.
56 57 58 |
# File 'lib/silhouette/processor.rb', line 56 def callers @callers end |
#calls ⇒ Object
Returns the value of attribute calls.
55 56 57 |
# File 'lib/silhouette/processor.rb', line 55 def calls @calls end |
#children ⇒ Object
Returns the value of attribute children.
56 57 58 |
# File 'lib/silhouette/processor.rb', line 56 def children @children end |
#key ⇒ Object (readonly) Also known as: method
Returns the value of attribute key.
58 59 60 |
# File 'lib/silhouette/processor.rb', line 58 def key @key end |
#self_sec ⇒ Object
Returns the value of attribute self_sec.
55 56 57 |
# File 'lib/silhouette/processor.rb', line 55 def self_sec @self_sec end |
#total_sec ⇒ Object
Returns the value of attribute total_sec.
55 56 57 |
# File 'lib/silhouette/processor.rb', line 55 def total_sec @total_sec end |
Instance Method Details
#add_cost(cost, last) ⇒ Object
72 73 74 75 |
# File 'lib/silhouette/processor.rb', line 72 def add_cost(cost, last) @total_sec += cost @self_sec += (cost - last) end |
#inc_call! ⇒ Object
68 69 70 |
# File 'lib/silhouette/processor.rb', line 68 def inc_call! @calls += 1 end |
#percentage(total) ⇒ Object
77 78 79 |
# File 'lib/silhouette/processor.rb', line 77 def percentage(total) @self_sec / total * 100.0 end |
#self_ms_per_call ⇒ Object
81 82 83 |
# File 'lib/silhouette/processor.rb', line 81 def self_ms_per_call (@self_sec * 1000.0 / @calls) end |
#total_ms_per_call ⇒ Object
85 86 87 |
# File 'lib/silhouette/processor.rb', line 85 def total_ms_per_call (@total_sec * 1000.0 / @calls) end |