in reply to performance profiling

Combining your request with grep's response, I wonder if you'd want to do something like this:

sub section($&) { my $name = shift; my $code = shift; use Benchmark; my $start = Benchmark->new(); $code->(); my $end = Benchmark->new(); print STDERR "Section $name: ", timestr(timediff($end, $start)), "\n +"; }
Then you call it like this:
section A => { ... do things ... }; section B => { ...do some other stuff... } section C => { ...why not more stuff here... ...and some more!... }
Warning: completely untested ;-)

Replies are listed 'Best First'.
Re^2: performance profiling
by thedoe (Monk) on Sep 25, 2006 at 16:45 UTC

    While I love the idea of this combination, I have a feeling it will give me some difficulty with variable scoping. Nice idea though as a way to reduce the complexity I was worried about!