At the very end of everything, you will likely want a nice clean report of everything.
my $bench = Tool::Bench->new; $bench->add_items( true => sub{1}, die => sub{die}, ls => {code => sub{qx{ls}}, note => 'some note', }, sleep => sub{sleep(1)}, ); $bench->run(4); print $bench->report(format => 'Text'); min max total avg count name 0.000 0.000 0.000 0.000 4 true 0.000 0.000 0.000 0.000 4 die 0.002 0.002 0.009 0.002 4 ls [some note] 1.000 1.000 4.000 1.000 4 sleep
This is the method that $bench->report will call to build the actual report. The most important thing that is passed along by $bench is the item objects.
$bench->report(format => 'Text');
Will end up calling 'report' looking like:
Tool::Bench::Report::Text->new->report(items => [...]);
Common practice is that you return the report, rather then printing. This allows the user to decide what they want to do with that report on there end.
To install Tool::Bench, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tool::Bench
CPAN shell
perl -MCPAN -e shell install Tool::Bench
For more information on module installation, please visit the detailed CPAN module installation guide.