Skip to content

Instantly share code, notes, and snippets.

@arielvalentin
Last active December 21, 2015 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielvalentin/6349470 to your computer and use it in GitHub Desktop.
Save arielvalentin/6349470 to your computer and use it in GitHub Desktop.
Enable profiling for jruby apps deployed to torquebox
require 'rubygems'
require 'rack'
require 'jruby/profiler'
app = lambda {|env|
profile_data = JRuby::Profiler::profile do
output = (0..50).map do |i|
50 * i
end
puts output
end
my_output_stream = java.io.ByteArrayOutputStream.new
print_stream = java.io.PrintStream.new(my_output_stream)
profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
profile_printer.printProfile(print_stream)
result = [my_output_stream.toString]
[200, { 'Content-Type' => 'text/plain' }, result]
}
run app
JRUBY_OPTS='--profile.api' torquebox run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment