in reply to NYTProf doesn't profile through a system or exec call

Not to be obtuse, but is there a reason you can't just profile scriptB independently? You could do this either by directly invoking it w/ perl -d:NYTProf scriptB, or if it needs internal parameters from the script, like

@commands = qw( perl -d:NYTProf scriptB val1 val2 ); exec(@commands);
I'm pretty sure that you'll get erroneous results if you try to profile both simultaneously.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: NYTProf doesn't profile through a system or exec call
by moritz (Cardinal) on Oct 22, 2013 at 07:11 UTC
    I'm pretty sure that you'll get erroneous results if you try to profile both simultaneously.

    But there's a simple solution to that: set the environment variable NYTPROF to addpid=1, then the profile for each process is written to a different file.

    Then one can either analyze each file separately with nytprofhtml -f nytprof.out.$PID, or run nytprofmerge -o nytprof.merged nytprof.out.*; nytprofhtml -f nytprof.merged to merge them all into one report.

    And to make sure that all perl processes are profiled, one can set the PERL5OPT environment variable to -d:NYTPProf.