Last active
December 21, 2015 18:48
-
-
Save arielvalentin/6349470 to your computer and use it in GitHub Desktop.
Enable profiling for jruby apps deployed to torquebox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JRUBY_OPTS='--profile.api' torquebox run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment