Using native int support
my $N = 100000; my $N = 100000; my int $i = 0; my int $i = 0; my int $j = 0; # start timer # start timer while $j < $N { for 0..^$N -> int $j { $i = $i + $j; $i = $i + $j; $j = $j + 1; } } # stop timer # stop timer
Results (seconds):
2011.01 2011.07 2012.01 2012.06 Perl 5.14 while 0..^N 23.04 14.43 2.24 1.63 0.02 for 0..^N 34.93 26.90 1.43 1.09 0.02 startup 0.62 0.59 0.12 0.09 0.005 while + int 1.44 1.00 for + int 0.97 0.74