JSON format profile printer (additions) #326

Merged
merged 3 commits into from Oct 27, 2012

Conversation

Projects
None yet
3 participants
@iconara
Contributor

iconara commented Oct 1, 2012

This is some additions to pull request #270, as per the discussion there.

I've added a layer of indirection between Ruby#printProfileData and the profile printers to make it possible to write a profile to a file. I also added ProfilePrinter#printHeader and #printFooter to make it possible to write all thread profiles into the same file when the format is HTML or JSON, without the output being all weird. I've also updated all profile printers to support this.

All changes should be backwards compatible, and I've marked the old version of Ruby#printProfileData that took a PrintStream as deprecated.

I've added an optional argument to --profile.xxx that is the file to write to. Please check that part extra carefully so that I haven't done anything stupid. There wasn't any other argument that took optional parameters on the form --xyz optarg, only arguments like -Ioptarg or that always expected a value. The way I did it was by checking if there is one more argument, and making sure that argument doesn't start with a dash. It will fail in this case: ruby --profile.json hello_world.rb, because hello_world.rb will be interpreted as the argument to --profile.json, not the script to run. I don't know if this is acceptable. Maybe it would be better to do it like --profile.json=output.json, but that's not how the other arguments that take values work (e.g. --compat RUBY_18).

I'm not entirely satisfied with the way profiles are printed, and I'd like to do some more changes to structure it differently, but I think that another pull request that can aim for a later release.

iconara added some commits Aug 25, 2012

Profile reports can now be written to a file
Support for writing profile reports to files, notably support for writing profiles from multiple threads to the same JSON or HTML file without syntax errors.

There's a new abstraction that handles profile printing: ProfileOutput. Together with new methods on ProfilePrinter, printHeader, printFooter and a new parameter to printProfile (first), it can orchestrate the the profile printers so that they print the right things at the right time.

@iconara iconara referenced this pull request Oct 1, 2012

Merged

JSON format profile printer #270

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Oct 6, 2012

Member

Theo, we will merge this right after final for 1.7.1. rc2 (which very very very likely will be 1.7.0) will be out on Monday and although this all looks solid to me is just a tad too close to this release.

Member

enebo commented Oct 6, 2012

Theo, we will merge this right after final for 1.7.1. rc2 (which very very very likely will be 1.7.0) will be out on Monday and although this all looks solid to me is just a tad too close to this release.

@iconara

This comment has been minimized.

Show comment
Hide comment
@iconara

iconara Oct 6, 2012

Contributor

Thanks! Getting it into 1.7.0 would have been awesome, but I completely understand that that is not possible, no problem at all. I'm just happy that you like it.

Contributor

iconara commented Oct 6, 2012

Thanks! Getting it into 1.7.0 would have been awesome, but I completely understand that that is not possible, no problem at all. I'm just happy that you like it.

headius added a commit that referenced this pull request Oct 27, 2012

@headius headius merged commit 7ba1531 into jruby:master Oct 27, 2012

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment