Re: [ANNOUNCE] Test::Benchmark
Fergal Daly wrote:
NAME
Test::Benchmark - Make sure something really is faster
SYNOPSIS
is_faster(-10, sub {...}, sub {...}, "this is faster than that")
is_faster(5, -10, sub {...}, sub {...}, "this is 5 times faster than that")
is_n_times_faster(5, -10, sub {...}, sub {...}, "this is 5 times faster than
that")
is_faster(-10, $bench1, $bench2, "res1 was faster than res2");
Hi Fergal,
Id like to see a slightly different interface:
is_faster( sub{}, sub{}, "1st is faster");
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
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
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)
package Benchmark::Table;
# the AoA returned by Benchmark::cmpthese() - non-existent in 5.00503s
version
# for a 2 test cmpare, gives 3 x 3 matrix: labels, slower, faster
package Benchmark::Comparison;
# an array of Benchmark objects, returned by timethese
Also, FWIW, I still want some support for throwing to screen via diag()
Other comments;
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] ?
HISTORY
This came up on the perl-qa mailing list, no one else.
incomplete sentence
Re: [ANNOUNCE] Test::Benchmark
Fergal Daly wrote:
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
Benchmark defaults to -3. Its hard to argue against keeping (or
implicitly using) that default.
ie - with optional arguments, and the ability to test for a float-val.
OTOH - this might be too DWEOM? ish
DWEOM?
aka Magic. a term that Tom Christiansen dredged out of old English, (or
is that Middle Earth)
see perlopentut or http://www.gregorpurdy.com/gregor/wow/000438.html
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.
or, more like Benchmark::timethese(). this form also allows 3 or more
I think I'll call that is_fastest().
youre way too logical :-)
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.
yeah - thats why I was thinking to slap a few new classes on/into it via TB.
A well-marked living-room invasion as it were.
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.
that sounds good - what Im hoping for is something like these
for 5.00503:
Benchmark: running DD, EzDD, each for at least 3 CPU seconds...
DD: 3 3.15 0.01 0 0 2399 none @ 759.18/s (n=2399)
EzDD: 3 3 0.01 0 0 2400 none @ 797.34/s (n=2400)
5.6.2
# EzDD 10582/3.23 = 3276.161
# DD 8616/3.17 = 2717.981
5.8.2
# Rate DD EzDD
# DD 2011/s -- -14%
# EzDD 2335/s 16% --
my t/speed.t does various unholy version contortions, that would hopefully
be obsoleted by Test::Benchmark
Re: [ANNOUNCE] Test::Benchmark
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
