perl5 -d:SmallProf test.pl
where <num> is the number of times that the line was executed, <time> is the amount of time spent executing it and <file>, <line> and <text> are the filename, the line number and the actual text of the executed line (read from the file).
Eval lines print <num> and <time> like the others, but also print the package, the eval number and, if possible, the text of the line.
The package uses the debugging hooks in Perl and thus needs the -d switch, so to profile test.pl, use the command:
perl5 -d:SmallProf test.pl
Once the script is done, the statistics in smallprof.out can be sorted to show which lines took the most time. The output can be sorted to find which lines take the longest, either with the sort command:
sort -nrk 2 smallprof.out | less
or a perl script:
open(PROF,"smallprof.out");
@sorted = sort {(split(/\s+/,$b))[2] <=>
(split(/\s+/,$a))[2]} <PROF>;
close PROF;
print join('',@sorted);
$DB::drop_zeros = 1.
@{'_<filename'} array for some evals is empty. When this is true, there isn't a lot that
can be done.
The conversion to the Win32 version is done during the call to Makefile.PL. This seems fairly inappropriate, but I'm not sure where better to do it.
Comments, advice and questions are welcome. If you see inefficent stuff in this module and have a better way, please let me know.