Skip to content

Instantly share code, notes, and snippets.

@tom-lpsd
Created July 23, 2010 02:21
Show Gist options
  • Save tom-lpsd/486925 to your computer and use it in GitHub Desktop.
Save tom-lpsd/486925 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Benchmark qw/cmpthese/;
sub ret_by_value {
my $n = shift;
my @seq = (0..$n);
return @seq;
}
sub ret_by_ref {
my $n = shift;
my @seq = (0..$n);
return \@seq;
}
cmpthese(10000, {
v => sub { (ret_by_value(10000))[0]},
r => sub { (ret_by_ref(10000))->[0] },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment