Author: tim.bunce
Date: Fri Dec  5 04:31:51 2008
New Revision: 643

Modified:
    trunk/NYTProf.xs
    trunk/lib/Devel/NYTProf/Data.pm
    trunk/lib/Devel/NYTProf/SubInfo.pm

Log:
Add NYTP_SIi_CALLED_BY element to sub info ({ fid => { line => [...] } })


Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs    (original)
+++ trunk/NYTProf.xs    Fri Dec  5 04:31:51 2008
@@ -112,7 +112,8 @@
  #define NYTP_SIi_PROFILE     7   /* ref to profile object */
  #define NYTP_SIi_REC_DEPTH   8   /* max recursion call depth */
  #define NYTP_SIi_RECI_RTIME  9   /* recursive incl real time in sub */
-#define NYTP_SIi_elements   10   /* highest index, plus 1 */
+#define NYTP_SIi_CALLED_BY  10   /* { fid => { line => [...] } } */
+#define NYTP_SIi_elements   11   /* highest index, plus 1 */

  /* indices to elements of the sub call info array */
  #define NYTP_SCi_CALL_COUNT  0   /* count of calls to sub */
@@ -3252,6 +3253,8 @@
                  if (!SvROK(sv))                   /* autoviv */
                      sv_setsv(sv, newRV_noinc((SV*)newHV()));

+                sv_setsv(*av_fetch(subinfo_av, NYTP_SIi_CALLED_BY, 1), sv);
+
                  len = sprintf(text, "%u", fid);
                  sv = *hv_fetch((HV*)SvRV(sv), text, len, 1);
                  if (!SvROK(sv))                   /* autoviv */
@@ -3579,6 +3582,7 @@
      newCONSTSUB(stash, "NYTP_SIi_PROFILE",      newSViv(NYTP_SIi_PROFILE));
      newCONSTSUB(stash, "NYTP_SIi_REC_DEPTH",     
newSViv(NYTP_SIi_REC_DEPTH));
      newCONSTSUB(stash, "NYTP_SIi_RECI_RTIME",    
newSViv(NYTP_SIi_RECI_RTIME));
+    newCONSTSUB(stash, "NYTP_SIi_CALLED_BY",     
newSViv(NYTP_SIi_CALLED_BY));
      /* NYTP_SCi_* */
      newCONSTSUB(stash, "NYTP_SCi_CALL_COUNT",    
newSViv(NYTP_SCi_CALL_COUNT));
      newCONSTSUB(stash, "NYTP_SCi_INCL_RTIME",    
newSViv(NYTP_SCi_INCL_RTIME));

Modified: trunk/lib/Devel/NYTProf/Data.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Data.pm     (original)
+++ trunk/lib/Devel/NYTProf/Data.pm     Fri Dec  5 04:31:51 2008
@@ -77,11 +77,12 @@

      my $profile = load_profile_data_from_file($file);
      bless $profile => $class;
-    #use Data::Dumper; warn Dumper($profile->{fid_fileinfo});

      my $fid_fileinfo = $profile->{fid_fileinfo};
      my $sub_subinfo  = $profile->{sub_subinfo};
      my $sub_caller   = $profile->{sub_caller};
+
+    #use Data::Dumper; warn Dumper($sub_subinfo);

      # add profile ref so fidinfo & subinfo objects
      # XXX circular ref, add weaken

Modified: trunk/lib/Devel/NYTProf/SubInfo.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/SubInfo.pm  (original)
+++ trunk/lib/Devel/NYTProf/SubInfo.pm  Fri Dec  5 04:31:51 2008
@@ -8,7 +8,7 @@
      NYTP_SIi_FID NYTP_SIi_FIRST_LINE NYTP_SIi_LAST_LINE
      NYTP_SIi_CALL_COUNT NYTP_SIi_INCL_RTIME NYTP_SIi_EXCL_RTIME
      NYTP_SIi_SUB_NAME NYTP_SIi_PROFILE
-    NYTP_SIi_REC_DEPTH NYTP_SIi_RECI_RTIME
+    NYTP_SIi_REC_DEPTH NYTP_SIi_RECI_RTIME NYTP_SIi_CALLED_BY
  );

  use List::Util qw(sum min max);
@@ -25,6 +25,9 @@
  sub recur_max_depth { shift->[NYTP_SIi_REC_DEPTH] }
  sub recur_incl_time { shift->[NYTP_SIi_RECI_RTIME] }

+# { fid => { line => [ count, incl_time ] } }
+sub callers    { shift->[NYTP_SIi_CALLED_BY] }
+
  sub is_xsub {
      my $self = shift;

@@ -77,18 +80,6 @@
          NYTP_SIi_REC_DEPTH, NYTP_SIi_RECI_RTIME
      ];
      return [EMAIL PROTECTED];
-}
-
-sub callers {
-    my $self = shift;
-
-    # { fid => { line => [ count, incl_time ] } }
-    my $callers = $self->profile->{sub_caller}->{$self->subname}
-        or return undef;
-
-    # XXX should 'collapse' data for calls from eval fids
-    # (with an option to not collapse)
-    return $callers;
  }

  sub caller_fids {

--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---

Reply via email to