Author: tim.bunce
Date: Thu Nov 6 15:48:49 2008
New Revision: 590
Modified:
trunk/lib/Devel/NYTProf/Data.pm
trunk/lib/Devel/NYTProf/Test.pm
Log:
Further optimizations.
Remove use strict & warnings from Devel/NYTProf/Test.pm, added in previous
commit, as they affect the test results.
Modified: trunk/lib/Devel/NYTProf/Data.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Data.pm (original)
+++ trunk/lib/Devel/NYTProf/Data.pm Thu Nov 6 15:48:49 2008
@@ -263,6 +263,26 @@
}
+sub caller_fid_2_subname_map {
+ my $self = shift;
+
+ my $caches = $self->_caches;
+ my $cache_key = "caller_fid_2_subname_map";
+ return $caches->{$cache_key} if $caches->{$cache_key};
+
+ my $sub_caller = $self->{sub_caller} || {};
+ my %map;
+ while (my ($subname, $fid_hash) = each %$sub_caller) {
+ while ( my ($caller_fid, $line_calls_hash) = each %$fid_hash ) {
+ $map{ $caller_fid }{ $subname } = $line_calls_hash;
+ }
+ }
+
+ $caches->{$cache_key} = \%map;
+ return \%map;
+}
+
+
sub inc {
# XXX should return inc from profile data, when it's there
@@ -908,7 +928,6 @@
=cut
-
sub line_calls_for_file {
my ($self, $fid, $flatten_evals) = @_;
$fid = $self->resolve_fid($fid);
@@ -916,19 +935,23 @@
my $sub_caller = $self->{sub_caller}
or return;
- # hash of fids we're interested in
- my %fids = ($fid => 1);
+ # list of fids we're interested in
+ my @fids = ($fid);
# add in all the fids for evals compiled in this fid
- my $b2e = $self->base_fid_2_eval_fids_map($flatten_evals);
- $fids{$_} = 1 for @{ $b2e->{$fid} || [] };
+ my $eval_fids =
$self->base_fid_2_eval_fids_map($flatten_evals)->{$fid};
+ push @fids, @$eval_fids if $eval_fids;
+
+ # { fid => { subname => { line => count, ... }, ... }, ... }
+ my $caller_fid_2_subname_map = $self->caller_fid_2_subname_map;
my $line_calls = {};
- # search through all subs to find those that were called
- # from the fid we're interested in, or any eval fids in that
- while (my ($subname, $fid_hash) = each %$sub_caller) {
+ # for the fid we're interested in, and all the related eval fids
+ # loop over the sub calls made by those fids
+ for my $caller_fid (@fids) {
+ my $subs_called_hash = $caller_fid_2_subname_map->{$caller_fid}
+ or next;
- while ( my ($caller_fid, $line_calls_hash) = each %$fid_hash ) {
- next unless $fids{ $caller_fid };
+ while (my ($subname, $line_calls_hash) = each %$subs_called_hash) {
my $caller_fi = $self->fileinfo_of($caller_fid);
my ($outer_fi, $outer_line) = $caller_fi->outer(1);
Modified: trunk/lib/Devel/NYTProf/Test.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Test.pm (original)
+++ trunk/lib/Devel/NYTProf/Test.pm Thu Nov 6 15:48:49 2008
@@ -1,9 +1,6 @@
package # hide from pause package indexer
Devel::NYTProf::Test;
-use strict;
-use warnings;
-
# this module is just to test the test suite
# see t/test60-subname.p for example
--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---