Two suggestions:
use Benchmark qw/timethese/; use strict; use warnings; my $array = [1..10000]; timethese(10000, {"straight" => sub {straight($array)}, "flatten" => s +ub {flatten(@$array)}}); sub straight { ; } sub flatten { ; }
Benchmark: timing 10000 iterations of flatten, straight... flatten: 6 wallclock secs ( 5.08 usr + 0.00 sys = 5.08 CPU) @ 19 +69.28/s (n =10000) straight: 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU) (warning: too few iterations for a reliable count)
In reply to Re: Notes from the Refactoring Ward
by pg
in thread Notes from the Refactoring Ward
by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |