Attribute::Benchmark - dead easy benchmarking
#!/usr/bin/env perl use Attribute::Benchmark; sub foo :Benchmark { 1 for 0..10; } sub bar1 :Benchmark(bar) { 1 for 0..1000; }
That's all folks!
Attribute::Benchmark provides a :Benchmark attribute for subs. Just import it into a script, write the subs you wish to compare, and add the :Benchmark attribute to each. Then run your script.
:Benchmark
No need to use strict or use warnings - Attribute::Benchmark does that for you.
use strict
use warnings
By default Attribute::Benchmark uses cmpthese(-3, \%subs) but the iteration count can be changed in the import statement:
cmpthese(-3, \%subs)
use Attribute::Benchmark (100);
Don't forget the parentheses; otherwise Perl will assume you want version 100.0 of Attribute::Benchmark!
Attribute::Benchmark will use the name of the sub as the label for the benchmark results (e.g. "foo" above). But you can provide an explicit label for a result like:
sub bar1 :Benchmark(bar)
Easy, peasy, lemon squeezy.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Attribute-Benchmark.
Benchmark.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Attribute::Benchmark, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Attribute::Benchmark
CPAN shell
perl -MCPAN -e shell install Attribute::Benchmark
For more information on module installation, please visit the detailed CPAN module installation guide.