On Wed, Dec 17, 2003 at 09:28:48AM -0700, Jim Cromie wrote:
> Hi Fergal,
> 
> Id like to see a slightly different interface:
> 
>    is_faster( sub{}, sub{}, "1st is faster");

This would be nice but what value should I use for iterations? I suppose -1
would be safe enough, anything that takes longer than 1 second probably
doesn't need more than 1 iteration to see if it's faster - unless the times
are very close, in which case the test is probably pointless. So that's a
yes I guess.

>    is_faster( 5.0, sub{}, sub{}, "1st is 5.0 x faster");
>    is_faster( 0.5, sub{}, sub{}, "1st is 1/2 as fast");
>    is_faster( 1000, sub{}, sub{}, "1st is faster over 1000 iterations");
>    is_faster( -3, sub{}, sub{}, "1st is faster over 3 second test");
> 
> ie - with optional arguments, and the ability to test for a float-val.
> OTOH - this might be too DWEOM? ish

DWEOM? I don't fancy the float stuff. I think it's doable but if someone
who's not familiar with the module is reading the test script they could
very easily misunderstand it, unless they read the docs very carefully. It
also suffers from the "how long should I run this for?" problem except now
I'm not sure that -1 is a suitable value for these because now there's a
potentially large factor multiplying the result.

> or, more like Benchmark::timethese().  this form also allows 3 or more tests
> 
>    is_faster( test1, { test1 => sub{}, test2 => sub{}, test3=> sub{} }, 
> "test1 is fastest");
> 
> it is doable, since
> { no warnings; if ( $_[0] and $_[0] == 0 and $_[0] ne '' ) # like timethese

I think I'll call that is_fastest().

> FWIW, I started messing about with the TB <=> Benchmark relationship..
> with the notion that a few new Benchmark::* classes could represent the
> Benchmark results more portably than the various versions of Benchmark do.
> (notably the old ones)

Benchmark itself could do with refactoring, I though about doing it but then
decided against it because people would have to upgrade to use it or I'd
have to write two versions of T::B.

> Also, FWIW, I still want some support for throwing to screen via diag()

It dumps the benchmarks to the screen when the test fails. I can stick in a
verbose flag somewhere to make it do that all the time.

> >DEPENDENCIES
> >   Benchmark, Test::Builder but they come with most Perl's.
> > 
> >
> 
> is that perls, perl's, Perls ?   You can avoid the whole issue;
> Benchmark, which is standard with perl5.00503+
> Test::Builder, which is standard with perl 5.6.[01] ?

Indeed, "Perls" is correct. I think I've seen too many corner shop signs.

F

Reply via email to