Skip to content

Instantly share code, notes, and snippets.

@avkhozov
Created June 21, 2011 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avkhozov/1037210 to your computer and use it in GitHub Desktop.
Save avkhozov/1037210 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Benchmark qw(:all);
sub with_return {
my ($x, $y) = @_;
return $x, $y;
}
sub without_return {
my ($x, $y) = @_;
($x, $y);
}
cmpthese(
10_000_000,
{ 'with return' => \&with_return,
'without return' => \&without_return,
}
);
__END__
C:\Users\avkhozov>perl ret.t
Rate with return without return
with return 3885004/s -- -1%
without return 3909304/s 1% --
C:\Users\avkhozov>perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment