Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/perl
use Modern::Perl;
use Benchmark 'cmpthese';
sub with_eval
{
eval
{
my ($a, $b) = (2, 4);
my $c = $a+$b;
}
}
sub without_eval
{
my ($a, $b) = (2, 4);
my $c = $a+$b;
}
cmpthese(10_000_000, {
'with eval' => \&with_eval,
'without eval' => \&without_eval
});
__DATA__
$ perl eval.pl
Rate with eval without eval
with eval 1862197/s -- -25%
without eval 2493766/s 34% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.