use Benchmark qw/timethese/; use strict; use warnings; my $array = [1..10000]; timethese(10000, {"straight" => sub {straight($array)}, "flatten" => sub {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) @ 1969.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)