Closed fidalgo closed 1 year ago
That should be easy to do, IIRC. Wanna take a whack at it?
Meanwhile maybe you can do something like:
def capture_ips_report(label, &block)
old_stdout = $stdout
$stdout = StringIO.new
::Benchmark.ips do |x|
# add more stuff here
x.report(label) do
block.call
end
end
# return the captured output
$stdout.string
ensure
$stdout = old_stdout
end
The function that does the printing should just take an optional output stream. It's the simplest and most flexible solution - can output to pipe, stderr, stringio, etc
if you don't want the comparison results, you create a suite and have that output to the appropriate output.
capture!
will not be captured, that may be possible at some time.
my_stream = StringIO.new
Benchmark.ips(:quiet => true, :suite => MySuite.new(my_stream)) do |x|
x.report(label) { block.call }
end
MySuite
can probably be ripped off of StdoutReport
I'll see if I can tweak that file to let you output to any file.
The changes to Compare
will probably be more work.
Does #89 meet your needs? Please comment there if you need something different
--K
Thanks @kbrock I made a comment on the PR.
Just wondering what the status of this is @nateberkopec @ioquatix @kbrock as this is a big pain point for us too
I dont really remember why I closed #89. I think someone needs to take #89 and reopen it, I can't because the original branch was deleted.
@nateberkopec do you want me to push this again?
@kbrock Yes, please! Sorry I ever closed it
Closed by #111
It would be nice, to have a way to capture the output to a String in order to print it or send it to an external service, like Bugsnag. Also in a PASS like heroku it's hard to get the reports because the logs are combined from logger, stdout and stderr.
By output I mean the full report: