Open HertzDevil opened 1 week ago
I slightly question the exposure of raw Array(IPS::Entry)
rather than something that would allow a replacement of the inner structures.
That said it would be really cool if it were easier to export it to hdr histogram format so that it can be put into plotter .
Benchmark::IPS::Entry
is "public" insofar as it isn't marked as :nodoc:
. Indeed a lot of things under Benchmark
should have been protected or hidden.
ran_items
is always a fresh Array
, but the entries themselves are mutable and have reference semantics, so perhaps they have to be duplicated.
I like the reporter pattern. It enables different formats.
Benchmark.ips
always prints its result toSTDOUT
in a nicely formatted table:But often I want to use those numbers somewhere else, e.g. plotting a graph, and to avoid parsing the above table again, I take the returned
Benchmark::IPS::Job
(the docs don't really mention this) and post-process the items into a JSON:IMO this is still not straightforward enough, because I don't want to pollute
STDOUT
at all. It would be nice ifBenchmark.ips
itself supports those alternative formats out of the box. So I suggest implementing any of the following:Benchmark::IPS::Job#execute
and#report
, respectively.IO
toBenchmark.ips
and perform all the printing on thatIO
. Then one can passFile.open(File::NULL, "w")
or a custom no-opIO
to suppress the output.Create some kind of reporter interface and delegate printing to that. Something like:
Then I could write:
Additionally,
TableReporter
andMyJsonReporter
are both testable in isolation, without needing to mock a full benchmark run.Similar points probably hold for
Benchmark.bm
as well.