Created
July 23, 2010 02:21
-
-
Save tom-lpsd/486925 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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