Test::Benchmark

Test::Benchmark module is here to make sure something really is faster.
Download

Test::Benchmark Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Fergal Daly
  • Publisher web site:
  • http://search.cpan.org/~fdaly/Test-NoWarnings-0.084/lib/Test/NoWarnings.pm

Test::Benchmark Tags


Test::Benchmark Description

Test::Benchmark module is here to make sure something really is faster. Test::Benchmark module is here to make sure something really is faster.SYNOPSIS use Test::More test => 17; use Test::Benchmark; 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"); is_fastest("c", -1, {a => sub {...}, b => sub {...}, c => sub {...},);Sometimes you want to make sure that your "faster" algorithm really is faster than the old way. This lets you check. It might also be useful to check that your super whizzo XS or Inline::C version is actually faster.This module is based on the standard Benchmark module. If you have lots of timings to compare and you don't want to keep running the same benchmarks all the time, you can pass in a result object from Benchmark::timethis() instead of sub routine reference.USAGEThere are 3 functions exported: is_faster(), is_n_times_faster() and is_fastest(). Actually is_faster() is redundant because is_n_times_faster() can do the same thing just by setting n to 1.Anywhere you can pass a subroutine reference you can also pass in a Benchmark object. # call as # is_faster($times, $sub1, $sub2, $name) # is_faster($faster, $times, $sub1, $sub2, $name)If you leave the number of iterations blank then it will use Benchmark's default.is_faster()is_faster($times, $sub1, $sub2, $name)is_faster($factor, $times, $sub1, $sub2, $name)This runs each subroutine reference $times times and then compares the results. Instead of either subroutine reference you can pass in a Benchmark object. If you pass in 2 Benchmark objects then $times is irrelevant.If $times is negative then that specifies a minimum duration for the benchmark rather than a number of iterations (see Benchmark for more details). I strongly recommend you use this feature if you want your modules to still pass tests reliably on machines that are much faster than your own. 10000 iterations may be enough for a reliable benchmark on your home PC but it be just a twinkling in the eye of somebody else's super computer.If the test fails, you will get a diagnostic output showing the benchmark results in the standard Benchmark format.is_n_times_faster()is_n_times_faster($factor, $times, $sub1, $sub2, $name)This is exactly the same as the second form of is_faster but it's just explicit about the "n times" part.is_fastest()is_fastest($bname, $times, $bhash, $name)This takes a hash reference containing benchmark subroutines as values and their names as keys. It times each subroutine and checks that the one named in $bname was the fastest. If the test fails, it will print out a sorted list of the timings of all the subroutines. Requirements: · Perl


Test::Benchmark Related Software