Created
May 21, 2009 02:45
-
-
Save fujiwara/115235 to your computer and use it in GitHub Desktop.
This file contains 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 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