Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JRuby Profiler example code doesn't print header or footer #1394

Closed
justfalter opened this issue Jan 10, 2014 · 2 comments
Closed

JRuby Profiler example code doesn't print header or footer #1394

justfalter opened this issue Jan 10, 2014 · 2 comments
Milestone

Comments

@justfalter
Copy link

The example code provided on the wiki page for profiling will not print the header or footer for the chosen printer.

The code in question:

profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
profile_printer.printProfile(STDOUT)

This is especially important with ProfilePrinter implementations like HtmlProfilePrinter, which need to insert a proper header and footer in order for the resultant document to render properly.

I would recommend that the example code provided on the wiki page provide a more complete example, such as:

profile_printer = JRuby::Profiler::HtmlProfilePrinter.new(profile_data)
ps = java.io.PrintStream.new(STDOUT.to_outputstream)
printer.printHeader(ps)
printer.printProfile(ps)
printer.printFooter(ps)

It's easy to compare the two by running the following code, and then diffing profile_missing.html with profile.html:

printer = JRuby::Profiler::HtmlProfilePrinter.new(result)
File.open("profile_missing.html", "w") do |fio|
  printer.printProfile(fio)
end

File.open("profile.html", "w") do |fio|
  ps = java.io.PrintStream.new(fio.to_outputstream)
  printer.printHeader(ps)
  printer.printProfile(ps)
  printer.printFooter(ps)
end
@BanzaiMan
Copy link
Member

@justfalter Do you mind updating the Wiki?

@enebo
Copy link
Member

enebo commented Feb 17, 2017

Updated wiki.. closing.

@enebo enebo closed this as completed Feb 17, 2017
@enebo enebo added this to the Non-Release milestone Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants