Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Simplifying dprofpp Output

by djantzen (Priest)
on Mar 30, 2004 at 22:38 UTC ( [id://341120]=perlquestion: print w/replies, xml ) Need Help??

djantzen has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I'm trying to use dprofpp and the Devel::DProf to debug a set of modules. I run the script with

perl -d:DProf script.pl
to generate tmon.out, then use dprof with the -T option to get a nice call tree output. The problem is that the resulting file is close to 38,000 lines long, mostly with not so useful stuff like BEGIN and DESTROY blocks, thousands of DBI calls, and some calls to other sections of our codebase I don't care about. Is there any way to simplify the output to something usable, say, to give a list of modules to which subroutines must belong in order to show up in the output? Or maybe someone else has written a tool for filtering the output? At this point I'm thinking I may end up just writing a script to filter by module name myself. Any gotchas you can think of?

Thanks in Advance, David


"The dead do not recognize context" -- Kai, Lexx

Replies are listed 'Best First'.
Re: Simplifying dprofpp Output
by BrowserUk (Patriarch) on Mar 30, 2004 at 23:30 UTC

    You might want to take a look at devel::smallprof. It has a the facility to specify which packages should be profiled which allows you to concentrate your efforts on those modules under your purvue. It also profiles line-by-line rather than sub-by-sub, which I've found more useful.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail

      I looked briefly at that but figured it would actually be more verbose in this case because it goes line by line, but I didn't see the option to specify packages. Thanks, I'll check it out.


      "The dead do not recognize context" -- Kai, Lexx
        Yes, I agree with djantzen that it is more bombastic going line by line.
Re: Simplifying dprofpp Output
by djantzen (Priest) on Mar 30, 2004 at 23:17 UTC

    I just wrote a one-off script to filter the output, and it shrank the output down to about 10,000 lines, much improved. The basic idea is just to look for modules I care about and forbid some commonly occuring but unhelpful methods like BEGIN, AUTOLOADS, etc. Obviously the code isn't very generalizable but I wonder if the problem is more commonly encountered. I'd like it if the -T option took some options on what to display and what to omit.

    use strict; use warnings; setpriority(0, 0, 19); my ($dir, $forbidden_str, $in_file, @modules, $module_str, $out_file); $dir = "$ENV{HOME}/lib/Workflow"; $in_file = "$dir/DEBUG.txt"; $out_file = "$dir/FILTERED.txt"; opendir(DIR, $dir); foreach my $file (readdir(DIR)) { if ($file =~ /^(\w+)\.pm$/) { push (@modules, $1); } } closedir(DIR); $forbidden_str = 'BEGIN|DESTROY|AUTOLOAD'; $module_str = join('|', @modules); open(IN, $in_file); open(OUT, ">$out_file"); while(<IN>) { if ($_ =~ $module_str && $_ !~ /$forbidden_str/) { print(OUT $_); } } close(IN); close(OUT);

    Update: actually using the $dir variable for it's intended purpose :)


    "The dead do not recognize context" -- Kai, Lexx
Re: Simplifying dprofpp Output
by eXile (Priest) on Mar 31, 2004 at 03:09 UTC
    A small reduction in number of lines can be made by using the -t or -S option of dprofpp. From the man-page:
    -t Display subroutine call tree to stdout. Subroutine statis +tics are not displayed. When a function is called multiple consecu +tive times at the same calling level then it is displayed once +with a repeat count. -S Display merged subroutine call tree to stdout. Statistics + are displayed for each branch of the tree. When a function is called multiple (not necessarily consec +utive) times in the same branch then all these calls go into one +branch of the next level. A repeat count is output together with + com- bined inclusive, exclusive and kids time. Branches are sorted w.r.t. inclusive time.
    you could use this, together with 'grep' to get info on the modules you really want to (not) see. For instance:
    dprofpp -S | grep -v 'BEGIN'
    or
    dprofpp -S | egrep 'Showme|MeToo'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://341120]
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found