H
howa
hi,
consider the following codes...
it is interested that there is no performance gain when we use return
by reference...or is that perl already optimized them for us?
#--------------------------------------------------------------------
sub test {
my %h = (
"a" => "asdsaefsayd7asdsdsdsdsdsdsatd7as6fdsa76smndfkjtpyty",
"b" => "vdfdgdgregrehgregdsa6td76satd7as6fdsa76smndfdfdgfhf",
"c" => "zxczxrhsadsadhsayd7asysgdsa6td76satd7as6fdsa76hthth",
"d" => "jhthfgdsadsadhsayd7asysgdsa6td76satd7as6fdsahrhrhrh",
"e" => "sfeghhfhsadsadhsayd7asysgdsa6td76satd7as6fdsahththt",
"f" => "jgjgjgsadsadhsayd7asysgdsa6td76satd7as6fdseretttttg",
"g" => "ekreorrsadsadhsayd7asysgdsa6td76satd7as6fdsadgdgggg",
"h" => "sadsadhsayd7asysgdsa6td76satd7as6fdsa76smndfkjdfdfd",
"i" => "mhjghhtsadsadhsayd7asysgdsa6td76satd7ahghghrrtrtrrt",
"j" => "ewtyhrhsadsadhsayd7asysgdsa6td76satd7as6fdsa76smndf",
"k" => "ykiyuiyutdhsayd7asysgdsa6td76satd7as6fdsa76smndfkjd"
);
# return %h;
return \%h;
}
my $startTime = time();
for ($count=1; $count<500000; $count++) {
my $tmp = test();
}
my $endTime = time();
print $endTime - $startTime;
consider the following codes...
it is interested that there is no performance gain when we use return
by reference...or is that perl already optimized them for us?
#--------------------------------------------------------------------
sub test {
my %h = (
"a" => "asdsaefsayd7asdsdsdsdsdsdsatd7as6fdsa76smndfkjtpyty",
"b" => "vdfdgdgregrehgregdsa6td76satd7as6fdsa76smndfdfdgfhf",
"c" => "zxczxrhsadsadhsayd7asysgdsa6td76satd7as6fdsa76hthth",
"d" => "jhthfgdsadsadhsayd7asysgdsa6td76satd7as6fdsahrhrhrh",
"e" => "sfeghhfhsadsadhsayd7asysgdsa6td76satd7as6fdsahththt",
"f" => "jgjgjgsadsadhsayd7asysgdsa6td76satd7as6fdseretttttg",
"g" => "ekreorrsadsadhsayd7asysgdsa6td76satd7as6fdsadgdgggg",
"h" => "sadsadhsayd7asysgdsa6td76satd7as6fdsa76smndfkjdfdfd",
"i" => "mhjghhtsadsadhsayd7asysgdsa6td76satd7ahghghrrtrtrrt",
"j" => "ewtyhrhsadsadhsayd7asysgdsa6td76satd7as6fdsa76smndf",
"k" => "ykiyuiyutdhsayd7asysgdsa6td76satd7as6fdsa76smndfkjd"
);
# return %h;
return \%h;
}
my $startTime = time();
for ($count=1; $count<500000; $count++) {
my $tmp = test();
}
my $endTime = time();
print $endTime - $startTime;