Hi, Can anyone give me some advice in profiling a subset of
subroutines inside multiple perl scripts through 1 entry point script
My aim is to profile certain parts of a big perl apps and excluding the part I am not interested in.
I know there is a -DProfile option but it profiles everything involved in EntryPoint.pl (see below).
But what if I only insterested in measuring the effects of
only certain subroutine/subroutines (for example, subroutine LogMe of LogMe.pl)
but excluding all the others, how can I do that?
LogMe.pl
use B; sub LogMe{ #calling other subroutines and do a lot of stuff print "logme is called\n"; B->new; B->_func2; };
commonRoutine.pm
package commonRoutine; sub new { my ($class, $cacheFileName) = @_; my $this = bless({}, ref($class) || $class); # Initialize member variables. $this->{initialized} = 1; $this->{lastFlushTime} = time(); return $this; } ## # Destructor. Clean up object. # sub DESTROY { my $this = shift; $this->_func2(); } sub _func3{ print "me\n"; } 1
EntryPoint.pl:
use A; use commonRoutine; do ('LogMe.pl'); sub enter{ A->new; commonRoutine->new; }
A.pm:
package A; use strict; use B; use commonRoutine; do ('LogMe.pl'); ## # Constructor. Initialize instance of object. # # @param $cacheFileName [in] Name of cache file. # # @return Instance of object or undef if failure. # sub new { print "A->new()\n"; my ($class, $cacheFileName) = @_; my $this = bless({}, ref($class) || $class); # Initialize member variables. $this->{initialized} = 1; $this->{lastFlushTime} = time(); $this->_func1(); return $this; } ## # Destructor. Clean up object. # sub DESTROY { my $this = shift; } sub _func1{ LogMe(); print "me\n"; } 1
B.pm
package B sub new { my ($class, $cacheFileName) = @_; my $this = bless({}, ref($class) || $class); # Initialize member variables. $this->{initialized} = 1; $this->{lastFlushTime} = time(); $this->_func2(); return $this; } ## # Destructor. Clean up object. # sub DESTROY { my $this = shift; $this->_func2(); } sub _func2{ print "me\n"; } 1

Edit: g0n - readmore tags


In reply to profiling a subset of subroutines inside multiple perl scripts through 1 entry point script by edwardt_tril

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.