On Wed, Jul 06, 2016 at 04:21:55AM -0700, Florido Paganelli wrote:
> Hi TIm, all
Hi Florido.
> I am trying to cherry pick selected values directly in the code, without
> letting nytprof create
> intermediate documents like html or csv. I just
> want to open the db and select what I need. I am using it for a big piece
> of software that is serving
> experiments at CERN called ARC [1].
>
> The issue I have now is that I know what kind of stats I want to get from
> a specific line of code but I
> don't really understand how to do it in the code. Here's a sample snippet:
>
> ---------------------------------------------------------------------
> # get the database file and open it as a perl datastructure
> my $perflogdir = '/var/log/arc';
> my $dbfile = 'infosys_20160704182046.perflog.raw';
> use Devel::NYTProf::Data;
> my $profile = Devel::NYTProf::Data->new( { filename =>
> $perflogdir.'/'.$dbfile, quiet => 1 } );
>
> # for selected subroutine, get time it took to run
> # There is a perl module called GMJobsInfo.pm
> # with a subroutine called get_gmjobs
> my $subinfo = $profile->subinfo_of('GMJobsInfo::get_gmjobs');
> my $getgmjobstotaltime = @{$subinfo}[4];
>
> # for selected line of code, get time it took to run
> my $linesinfo = $profile->fileinfo_of('GMJobsInfo.pm');
> my $info = @$linesinfo[7];
> my $fidline = $info->{fid_line_time};
> # 6: id assigned to GMJobsInfo
> # 151: line of open local files
> # strategy:
> # 1. get the pm file id
> # 2. get the fid_line_time datastructure
> # what is the fastest way? can it be done from $profile?
> my $linetime = @{@$fidline[6]}[157];
> ---------------------------------------------------------------------
>
> But I feel this is a little clunky and not very practical.
Ignoring clunky/impractical for now, does that code work for you?
> What is the best way to achieve the above in the code?
The above doesn't look like much code so if it works then I'm not clear
what your specific concerns are.
> Getting stats for subroutines and lines of code directly?
Isn't that what you've done above?
> Can you show me an example? The csv and html readers are not interesting.
> They parse everything. It is not what I need.
At their core they iterate over lines and subroutines and output data
for each. Some digging past the code doing the iteration should yield
some useful code snippits.
For subroutines, there's a module that provides a more abstract API:
https://metacpan.org/source/TIMB/Devel-NYTProf-6.03/lib/Devel/NYTProf/SubInfo.pm#
and a similar one for files:
https://metacpan.org/source/TIMB/Devel-NYTProf-6.03/lib/Devel/NYTProf/FileInfo.pm#
Using those avoids the need to break encapsulation.
I've not touched the code for a while so I'm rusty on the details. Sorry.
More specific questions might get more useful answers :)
Tim.
--
--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]
---
You received this message because you are subscribed to the Google Groups
"Devel::NYTProf Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.