-
-
Save kares/9948938 to your computer and use it in GitHub Desktop.
printing JRuby profiler data output (examples)
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 'jruby/profiler' | |
profile_data = JRuby::Profiler.profile do | |
# code to be profiled.... | |
end | |
# print data in flat format to STDOUT : | |
profile_printer = JRuby::Profiler::FlatProfilePrinter.new(profile_data) | |
profile_printer.printProfile(STDOUT) | |
# print the data to a string in graph format : | |
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 # Ruby String might puts to File etc. | |
# print the data directly to an output File in html format : | |
append = false | |
my_output_stream = java.io.FileOutputStream('/home/kares/profile.out', append) | |
print_stream = java.io.PrintStream.new(my_output_stream) | |
profile_printer = JRuby::Profiler::HtmlProfilePrinter.new(profile_data) | |
profile_printer.printProfile(print_stream) | |
my_output_stream.flush # to make sure it gets written down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment