JSON format profile printer

This is the start of a conversation, I don't expect this pull request to be merged in as-is. I hope that with your help I can make it into something that, IMHO, would improve the JRuby profilers usefulness greatly.

I've written a profile printer that outputs a raw profile in the form of a JSON document. My motivation is that I want to visualize the profiler output with GraphViz, like perftools.rb does, but I figured that instead of writing a DOT profile printer and add to the list of specialized profiler printers, I'd add a generic profile output format that could be used by others to visualize the profiler output in different ways. The existing HTML format could easily be ported to use the raw output, and be moved out of JRuby core, for example.

To give you an idea of what I'm trying to do, here's a picture (it's generated from an actual run of the profiler):

![](https://raw.github.com/iconara/dot_profile_printer/master/examples/example.png "Pretty graph")

[I've previously spiked the DOT format printing](https://github.com/iconara/dot_profile_printer), but because of how the profiler API works it's hard to do exactly what I want from the outside.

To go forward with this I'd like your input on a few things:

* Is this a good idea? (I spoke to Tom at JRubyConf EU and he seemed to like it)
* To be useful you need to be able to write the output to a file (this actually goes for the existing HTML format too), what do you think of making `ruby --profile.json=path/to/file.json` possible?
* Currently JRuby prints the profile of each thread separately. I would like to change that so that it would be possible to write the profiles of all threads into the same file. I can make the changes, but it would require much more invasive changes, so far I've only made additions, and if you have any opinions on how it should be done, please let me know.
* I've written tests for my JSON output, and I've run all the profiler printer tests, and the whole test suite. There's lots of failures, both with and without my code, so I can't be absolutely sure I haven't broken anything. It looks as if I get the same failures. Either I don't understand properly how to run the tests, or they haven't been updated in a while. If you like this patch, and if I'll continue to make changes to the profiler output, maybe I can clean up the old tests too.
* The output is JSON, but I didn't want to add a dependency on a full-fledged JSON library just to create the JSON, but maybe there's already something there I could use, I couldn't really tell. Since I didn't want to buffer the whole document in memory before printing it, but printing it completely streaming would require much more code, I made a hybrid: each method is rendered as a string, and printed separately, and since each method is just a few hundred bytes it felt like a good trade off. I think that part looks ok, but unfortunately printing the header properties and the ending "}" is different and ugly.
* All durations are in nanoseconds, but it seems to me like they only have millisecond resolution. I output the durations in decimal seconds, but if the resolution isn't greater than milliseconds I think I prefer to output in integer milliseconds.

Sorry if this way way too long, but I wanted to get all my thoughts down. This is my first JRuby patch and I want to get it right.