#!/usr/bin/perl -w use Benchmark; use strict; my $results = timethese( 30, { a => sub{my $total = 0; $total += $_ for(1..1e6);}, b => sub{my $total = 0; for(1..1e6){$total += $_;}}, } ); #### Benchmark: timing 30 iterations of a, b... a: 8 wallclock secs ( 8.30 usr + 0.00 sys = 8.30 CPU) @ 3.62/s (n=30) b: 9 wallclock secs ( 9.03 usr + 0.02 sys = 9.05 CPU) @ 3.32/s (n=30)