Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Created May 21, 2009 02:45
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 fujiwara/115235 to your computer and use it in GitHub Desktop.
Save fujiwara/115235 to your computer and use it in GitHub Desktop.
use Benchmark qw/:all/;
use List::Util qw/ sum /;
cmpthese(0, {
sum => sub { sum( 1 .. 1000 ) },
loop => sub {
my $x = 0;
$x += $_ for ( 1 .. 1000 );
},
});
__END__
Rate loop sum
loop 7423/s -- -86%
sum 54490/s 634% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment