Class: JRubyProf::ThreadSet

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby-prof/invocation_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(invocations, duration) ⇒ ThreadSet

Returns a new instance of ThreadSet.



6
7
8
9
10
11
12
13
# File 'lib/jruby-prof/invocation_set.rb', line 6

def initialize(invocations, duration)
  @invocations = invocations.map do |inv|
    c = inv
    c = c.parent while c.parent
    c
  end
  @duration = duration
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



4
5
6
# File 'lib/jruby-prof/invocation_set.rb', line 4

def duration
  @duration
end

#invocationsObject (readonly)

Returns the value of attribute invocations.



4
5
6
# File 'lib/jruby-prof/invocation_set.rb', line 4

def invocations
  @invocations
end

Class Method Details

.add_methods(h, inv, duration = nil, count = nil) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/jruby-prof/invocation_set.rb', line 25

def self.add_methods(h, inv, duration=nil, count=nil)
  return if inv.name =~ /CachingCallSite\.stop_tracing/ or inv.name =~ /JRubyProf\.stop/
  h[inv.name] ||= Method.new(inv.class_name, inv.method_name, inv.static?)
  h[inv.name].add_invocation(inv)
  inv.children.each do |child_inv|
    add_methods(h, child_inv)
  end
end

Instance Method Details

#lengthObject



15
16
17
# File 'lib/jruby-prof/invocation_set.rb', line 15

def length
  invocations.length
end

#top_level_durationObject



19
20
21
22
23
# File 'lib/jruby-prof/invocation_set.rb', line 19

def top_level_duration
  invocations.inject(0.0) do |m, inv| 
    m + inv.childrens_duration
  end
end