Revision: 1110
Author: [email protected]
Date: Mon Mar  8 01:47:05 2010
Log: Abstract writing sub info into NYTP_write_sub_info(), wrap it and use it
nytprofmerge.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1110

Modified:
 /trunk/FileHandle.h
 /trunk/FileHandle.xs
 /trunk/NYTProf.xs
 /trunk/bin/nytprofmerge

=======================================
--- /trunk/FileHandle.h Mon Mar  8 01:46:51 2010
+++ /trunk/FileHandle.h Mon Mar  8 01:47:05 2010
@@ -82,3 +82,6 @@
                              unsigned int last_sub_line);
 size_t NYTP_write_time_line(NYTP_file ofile, unsigned int elapsed,
                             unsigned int fid, unsigned int line);
+size_t NYTP_write_sub_info(NYTP_file ofile, unsigned int fid,
+                           const char *name, I32 len,
+ unsigned int first_line, unsigned int last_line);
=======================================
--- /trunk/FileHandle.xs        Mon Mar  8 01:46:57 2010
+++ /trunk/FileHandle.xs        Mon Mar  8 01:47:05 2010
@@ -840,6 +840,39 @@
 {
return write_time_common(ofile, NYTP_TAG_TIME_LINE, elapsed, fid, line);
 }
+
+size_t
+NYTP_write_sub_info(NYTP_file ofile, unsigned int fid,
+                    const char *name, I32 len,
+                    unsigned int first_line, unsigned int last_line)
+{
+    size_t total;
+    size_t retval;
+
+    total = retval = output_tag_int(ofile, NYTP_TAG_SUB_INFO, fid);
+    if (retval < 1)
+        return retval;
+
+    total += retval = output_str(ofile, name, (I32)len);
+    if (retval < 1)
+        return retval;
+
+    total += retval = output_int(ofile, first_line);
+    if (retval < 1)
+        return retval;
+
+    total += retval = output_int(ofile, last_line);
+    if (retval < 1)
+        return retval;
+
+    /* FIXME. Next time we change the file format, remove this:  */
+    /* how many extra items follow */
+    total += retval = output_int(ofile, 0);
+    if (retval < 1)
+        return retval;
+
+    return total;
+}

MODULE = Devel::NYTProf::FileHandle PACKAGE = Devel::NYTProf::FileHandle PREFIX = NYTP_

@@ -1008,3 +1041,20 @@
 unsigned int elapsed
 unsigned int fid
 unsigned int line
+
+size_t
+NYTP_write_sub_info(handle, fid, name, first_line, last_line)
+NYTP_file handle
+unsigned int fid
+SV *name
+unsigned int first_line
+unsigned int last_line
+    PREINIT:
+        STRLEN len;
+        const char *const p = SvPV(name, len);
+    CODE:
+        RETVAL = NYTP_write_sub_info(handle, fid,
+ p, SvUTF8(name) ? -(I32)len : (I32)len,
+                                     first_line, last_line);
+    OUTPUT:
+        RETVAL
=======================================
--- /trunk/NYTProf.xs   Mon Mar  8 01:46:51 2010
+++ /trunk/NYTProf.xs   Mon Mar  8 01:47:05 2010
@@ -3211,11 +3211,8 @@
             logwarn("Sub %s fid %u lines %lu..%lu\n",
sub_name, fid, (unsigned long)first_line, (unsigned long)last_line);

-        output_tag_int(out, NYTP_TAG_SUB_INFO, fid);
-        output_str(out, sub_name, sub_name_len);
-        output_int(out, first_line);
-        output_int(out, last_line);
-        output_int(out, 0);  /* how many extra items follow */
+        NYTP_write_sub_info(out, fid, sub_name, sub_name_len, first_line,
+                            last_line);
     }
 }

=======================================
--- /trunk/bin/nytprofmerge     Mon Mar  8 01:46:57 2010
+++ /trunk/bin/nytprofmerge     Mon Mar  8 01:47:05 2010
@@ -162,10 +162,7 @@
         my $output_fid = $pending_subs{"$fid,$first_line,$last_line,$name"};
         return unless defined $output_fid;

-        $out->write('s');
-        $out->output_int($output_fid);
-        $out->output_str($name);
-        $out->output_int($first_line, $last_line, 0);
+        $out->write_sub_info($output_fid, $name, $first_line, $last_line);
      },
      SUB_CALLERS => sub {
my (undef, $fid, $line, $count, $incl_time, $excl_time, $ucpu_time, $scpu_time, $reci_time, $rec_depth, $called, $caller) = @_;

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