Class: JRuby::Profiler::CallgrindPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby/profiler/callgrind_printer.rb

Instance Method Summary collapse

Instance Method Details

#get_info(serial) ⇒ Object

Returns filename, line number, method_name.

Parameters:

  • (Integer)

Returns:

  • filename, line number, method_name



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/jruby/profiler/callgrind_printer.rb', line 45

def get_info(serial)
  name = self.methodName(serial)
  file = '(jruby_runtime)'
  line = 0

  if pm = self.getProfileData().getProfiledMethods().get(serial)
    if m = pm.getMethod
      if m.respond_to?(:getFile)
        file = m.getFile
      end

      if m.respond_to?(:getLine)
        line = m.getLine
      end
    end
  end

  return [file, line, name]
end

#printFooter(out) ⇒ Object

Parameters:

  • out (IO)


11
12
# File 'lib/jruby/profiler/callgrind_printer.rb', line 11

def printFooter(out)
end

#printHeader(out) ⇒ Object

Parameters:

  • out (IO)


5
6
7
8
# File 'lib/jruby/profiler/callgrind_printer.rb', line 5

def printHeader(out)
  out.puts("events: process_time")
  out.puts()
end

#printProfile(out, is_first = false) ⇒ Object

Parameters:

  • out (IO)

    Where we want to write our output

  • is_first (Boolean) (defaults to: false)

    (false) Does nothing, at the moment



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jruby/profiler/callgrind_printer.rb', line 16

def printProfile(out, is_first=false)
  ti = getTopInvocation()
  methods = self.class.methodData(ti);

  methods.entrySet.each do |entry|
    serial = entry.key
    method_data = entry.value
    file, line, method_name = get_info(serial)
    out.puts("fl=#{file}")
    out.puts("fn=#{method_name}")
    out.puts("#{line} #{method_data.selfTime}")

    method_data.children.to_a().each do |child_id|
      next if self.isThisProfilerInvocation(child_id)
      f, l, n = get_info(child_id)
      invs = method_data.rootInvocationsOfChild(child_id)
      num_calls = method_data.invocationsOfChild(child_id).totalCalls
      out.puts("cfl=#{f}")
      out.puts("cfn=#{n}")
      out.puts("calls=#{num_calls} #{l}")
      out.puts("#{l} #{invs.totalTime()}")
    end

    out.puts()
  end
end