putting a name to it is painting a bullseye on it ;-)



I recently wrote a test to do a benchmark / performance test, and found it somewhat difficult to get the output out to screen, the STDOUT, STDERR takeover done by Test::More was catching, and counting it as errors. (i think, but its not pertinent)

I ended up doing this..

for $data ($AR, $HR, [EMAIL PROTECTED], $ezpr, $ddo) {

$rows = cmpthese(-3, {
'DD' => sub { Dumper ($data)},
'EzDD' => sub { $ezdd->($data)},
}, 'none');
# kinda hacked way of getting output..
for $r (@$rows) {
diag sprintf("%12s %12s %12s %12s", @$r);
}
}



IOW, since Benchmark::cmpthese() printing was blocked, I suppressed it, then printed the rows myself with diag().

SOOOO

Is there a Test::* enhancement latent here ?

I could hack Benchmark to accept print-styles "#$foo",
where $foo is :

     STYLE can be any of 'all', 'none', 'noc', 'nop'
                or 'auto'. 'all' shows each of the 5 times

thus sneaking in a prefix that might allow it out of the Test::More stdout/err box.
I dont know if this would work, but it sounds like a bad idea anyway-
it creates a dependency on a new Benchmark hack, which is in CORE,
and would then have to become dual-life.


Alternatively - Test::Benchmark could override the appropriate pieces
of Benchmark. This is only worthwhile if print "# foo" actually gets thru the
test framework.


Finally, and perhaps most practically, diag_code (&;$) could run the
subroutine within a box that lets the prints thru. The biggest problem is that
its probably hard to also catch errors/warnings etc that should be caught.


So what think yall ?



Reply via email to