profiling and timing Perl code

December 4th, 2003 at 1:06 pm

I’ve spent the morning so far poking around with -d:Dprof, tmon.out, Benchmark and friends. In the script I’m writing performance will likely be critical (unfortunately…), so I’m timing the basic operations to know where I stand.

It’s quite fun… I think there’s a problem with dprofpp though… If it shows a call of some function from a module, and this call is direct from another module, ModuleName::BEGIN is displayed instead… bug ? feature ?

Also, the output of timestr(timediff…)) from Benchmark is too wordly for visual output. I only care about the total CPU time (usr + sys). So, the following does the trick:

my $bench_obj = timediff($t2, $t1);
my $secs = $bench_obj->[2] + $bench_obj[1];
print "This took $secs secsn";

Related posts:

  1. Some benchmarking in Perl
  2. Compiling C DLLs and using them from Perl
  3. Win32::OLE with Perl, Open Office

Leave a Reply

To post code with preserved formatting, enclose it in `backticks` (even multiple lines)