Class: JRuby::Management::ProfilerMBean

Inherits:
JMX::DynamicMBean
  • Object
show all
Defined in:
lib/jruby/management/profiler_mbean.rb

Defined Under Namespace

Classes: JRuby.runtime

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.mbean_nameObject



31
32
33
# File 'lib/jruby/management/profiler_mbean.rb', line 31

def self.mbean_name
  "ProfilerMBean"
end

Instance Method Details

#dump_profile_info(path) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jruby/management/profiler_mbean.rb', line 18

def dump_profile_info(path)
  runtime = JRuby.runtime
  file = open(path, 'w+')
  runtime.thread_service.ruby_thread_map.each do |t, rubythread|
    file.puts("\n#{t} profile results:")
    context = JRuby.reference(rubythread).context
    profile_data = context.profile_data
    printer = runtime.instance_config.make_default_profile_printer(profile_data)
    printer.printProfile(file)
  end
  file.close
end

#enable_profilingObject



10
11
12
13
# File 'lib/jruby/management/profiler_mbean.rb', line 10

def enable_profiling
  JRuby.runtime.config.profiling_mode = org.jruby.RubyInstanceConfig::ProfilingMode::GRAPH
  JRuby.reference(JRuby.runtime.kernel).invalidate_cache_descendants
end