Class: Silhouette::ProfileNode

Inherits:
Object
  • Object
show all
Defined in:
lib/silhouette/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#callersObject

Returns the value of attribute callers.



56
57
58
# File 'lib/silhouette/processor.rb', line 56

def callers
  @callers
end

#callsObject

Returns the value of attribute calls.



55
56
57
# File 'lib/silhouette/processor.rb', line 55

def calls
  @calls
end

#childrenObject

Returns the value of attribute children.



56
57
58
# File 'lib/silhouette/processor.rb', line 56

def children
  @children
end

#keyObject (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_secObject

Returns the value of attribute self_sec.



55
56
57
# File 'lib/silhouette/processor.rb', line 55

def self_sec
  @self_sec
end

#total_secObject

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_callObject



81
82
83
# File 'lib/silhouette/processor.rb', line 81

def self_ms_per_call
    (@self_sec * 1000.0 / @calls)
end

#total_ms_per_callObject



85
86
87
# File 'lib/silhouette/processor.rb', line 85

def total_ms_per_call
    (@total_sec * 1000.0 / @calls)
end