On Thursday 04 December 2003 21:51, Michael G Schwern wrote:
> But it could be. It would be nice to have a test like "make sure the
> hand optimized version is faster than the unoptimized version" or "make sure
> the XS version is faster than the Perl version".
Yeah - this would probably be useful.
> Another useful sort of test would be "make sure this function runs in less
> than N perlmips time" where a perlmip is some unit of CPU time calibrated
> relative to the current hardware. So a pmip on machine A would be
> roughly twice as long as a pmip on a machine that's twice as fast.
> This enables us to test "make sure this isn't too slow".
Not so yeah - just like the mip, the pmip would be a bit to elusive and ever
changing for this to work quite as well as we'd like.
Anyway to do these you can do
my $res = timethese(10000, {a => $a_code, b => $b_code}, "none");
which will produce no output and $res will contain all the benchmark
information and you can then perform whatever tests you like on it.
If it's exists, Test::Benchmark should support something like
is_faster(10000, $XS_code, $perl_code, "XS is faster")
and maybe
is_n_times_faster(10000, 5, $XS_code, $perl_code, "XS is 5 times faster")
But I don't think that was what Jim wanted, it seemed like he was trying to
display benchmark info purely for informational purposes,
F