sub foo { ..... return @foo; } my $num_foo = foo( @args ); #### my @x = 1 .. 1_000_000; sub want { return wantarray ? @x : $#x + 1; } sub nowant { return @x; } cmpthese( -10, { '1nowant' => sub { my $x = nowant(); }, '2want' => sub { my $x = want(); }, '3nowant_list' => sub { my $x = () = nowant(); }, '4want_list' => sub { my $x = () = want(); }, }); -------- Benchmark: running 1nowant, 2want, 3nowant_list, 4want_list for at least 10 CPU seconds... 1nowant: 10 wallclock secs (10.25 usr + 0.00 sys = 10.25 CPU) @ 582570.73/s (n=5971350) 2want: 10 wallclock secs (10.05 usr + 0.00 sys = 10.05 CPU) @ 578237.81/s (n=5811290) 3nowant_list: 11 wallclock secs (10.84 usr + 0.00 sys = 10.84 CPU) @ 1.11/s (n=12) 4want_list: 11 wallclock secs (10.66 usr + 0.00 sys = 10.66 CPU) @ 1.13/s (n=12) Rate 3nowant_list 4want_list 2want 1nowant 3nowant_list 1.11/s -- -2% -100% -100% 4want_list 1.13/s 2% -- -100% -100% 2want 578238/s 52234049% 51366692% -- -1% 1nowant 582571/s 52625456% 51751600% 1% -- #### Benchmark: running 1nowant, 2want, 3nowant_list, 4want_list for at least 10 CPU seconds... 1nowant: 13 wallclock secs (10.67 usr + 0.00 sys = 10.67 CPU) @ 558715.46/s (n=5961494) 2want: 12 wallclock secs (10.66 usr + 0.00 sys = 10.66 CPU) @ 390887.71/s (n=4166863) 3nowant_list: 11 wallclock secs (10.75 usr + 0.00 sys = 10.75 CPU) @ 1.12/s (n=12) 4want_list: 11 wallclock secs (10.72 usr + 0.00 sys = 10.72 CPU) @ 1.12/s (n=12) Rate 3nowant_list 4want_list 2want 1nowant 3nowant_list 1.12/s -- -0% -100% -100% 4want_list 1.12/s 0% -- -100% -100% 2want 390888/s 35016924% 34919202% -- -30% 1nowant 558715/s 50051494% 49911815% 43% --