Class: NewRelic::Agent::ThreadProfile::Node
- Inherits:
-
Object
- Object
- NewRelic::Agent::ThreadProfile::Node
- Defined in:
- lib/new_relic/agent/thread_profiler.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line_no ⇒ Object
readonly
Returns the value of attribute line_no.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#runnable_count ⇒ Object
Returns the value of attribute runnable_count.
-
#to_prune ⇒ Object
Returns the value of attribute to_prune.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_child(child) ⇒ Object
-
#initialize(line, parent = nil) ⇒ Node
constructor
A new instance of Node.
-
#order_for_pruning(y) ⇒ Object
Descending order on count, ascending on depth of nodes.
- #prune! ⇒ Object
- #to_array ⇒ Object
- #total_count ⇒ Object
Constructor Details
#initialize(line, parent = nil) ⇒ Node
Returns a new instance of Node.
241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 241 def initialize(line, parent=nil) line =~ /(.*)\:(\d+)\:in `(.*)'/ @file = $1 @method = $3 @line_no = $2.to_i @children = [] @runnable_count = 0 @to_prune = false @depth = 0 parent.add_child(self) if parent end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
238 239 240 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 238 def children @children end |
#depth ⇒ Object
Returns the value of attribute depth.
239 240 241 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 239 def depth @depth end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
238 239 240 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 238 def file @file end |
#line_no ⇒ Object (readonly)
Returns the value of attribute line_no.
238 239 240 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 238 def line_no @line_no end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
238 239 240 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 238 def method @method end |
#runnable_count ⇒ Object
Returns the value of attribute runnable_count.
239 240 241 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 239 def runnable_count @runnable_count end |
#to_prune ⇒ Object
Returns the value of attribute to_prune.
239 240 241 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 239 def to_prune @to_prune end |
Class Method Details
.prune!(kids) ⇒ Object
284 285 286 287 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 284 def self.prune!(kids) kids.delete_if { |child| child.to_prune } kids.each { |child| child.prune! } end |
Instance Method Details
#==(other) ⇒ Object
254 255 256 257 258 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 254 def ==(other) @file == other.file && @method == other.method && @line_no == other.line_no end |
#add_child(child) ⇒ Object
275 276 277 278 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 275 def add_child(child) child.depth = @depth + 1 @children << child unless @children.include? child end |
#order_for_pruning(y) ⇒ Object
Descending order on count, ascending on depth of nodes
265 266 267 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 265 def order_for_pruning(y) [-runnable_count, depth] <=> [-y.runnable_count, y.depth] end |
#prune! ⇒ Object
280 281 282 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 280 def prune! Node.prune!(@children) end |
#to_array ⇒ Object
269 270 271 272 273 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 269 def to_array [[@file, @method, @line_no], @runnable_count, 0, @children.map {|c| c.to_array}] end |
#total_count ⇒ Object
260 261 262 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 260 def total_count @runnable_count end |