timethese (500,
{
test_a => q{
my $a = 0;
for (my $i = 0; $i < 100000; $i++) {
$a++;
}
},
test_b => q{
my $a = 0;
foreach (1 .. 100000) {
$a++;
}
}
}
);

Benchmark: timing 500 iterations of test_a, test_b...
test_a: 12 wallclock secs (11.63 usr + 0.00 sys = 11.63 CPU) @ 43.01/s (n=500)
test_b: 9 wallclock secs ( 9.63 usr + 0.00 sys = 9.63 CPU) @ 51.95/s (n=500)