Help for this page

Select Code to Download


  1. or download this
    for (my $i = 0; $i < 1000000; $i += 2) {$sum += $i}
    
  2. or download this
    for my $i (map {$_ * 2} 0 .. 1000000 / 2) {$sum += $i}
    
  3. or download this
    {
     my $i=0;
    ...
        $i+=2;
     }
    }
    
  4. or download this
    use strict;
    use Benchmark qw(cmpthese);
    ...
              Rate for(;;) foreach
    for(;;) 85.3/s      --    -40%
    foreach  143/s     68%      --