Revision: 1115
Author: [email protected]
Date: Mon Mar 8 01:47:36 2010
Log: Abstract writing source lines info into NYTP_write_src_line(), wrap it
and use
it from nytprofmerge.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1115
Modified:
/trunk/FileHandle.h
/trunk/FileHandle.xs
/trunk/NYTProf.xs
/trunk/bin/nytprofmerge
=======================================
--- /trunk/FileHandle.h Mon Mar 8 01:47:23 2010
+++ /trunk/FileHandle.h Mon Mar 8 01:47:36 2010
@@ -92,3 +92,5 @@
NV incl_utime, NV incl_stime, NV reci_rtime,
unsigned int depth,
const char *called_name, I32
called_name_len);
+size_t NYTP_write_src_line(NYTP_file ofile, unsigned int fid,
+ unsigned int line, const char *text, I32
text_len);
=======================================
--- /trunk/FileHandle.xs Mon Mar 8 01:47:29 2010
+++ /trunk/FileHandle.xs Mon Mar 8 01:47:36 2010
@@ -931,6 +931,29 @@
return total;
}
+
+size_t
+NYTP_write_src_line(NYTP_file ofile, unsigned int fid,
+ unsigned int line, const char *text, I32 text_len)
+{
+ size_t total;
+ size_t retval;
+
+ total = retval = output_tag_int(ofile, NYTP_TAG_SRC_LINE, fid);
+ if (retval < 1)
+ return retval;
+
+ total += retval = output_int(ofile, line);
+ if (retval < 1)
+ return retval;
+
+ total += retval = output_str(ofile, text, text_len);
+ if (retval < 1)
+ return retval;
+
+ return total;
+}
+
MODULE = Devel::NYTProf::FileHandle PACKAGE =
Devel::NYTProf::FileHandle PREFIX = NYTP_
@@ -1145,3 +1168,18 @@
SvUTF8(called_sub) ?
-(I32)called_len : (I32)called_len);
OUTPUT:
RETVAL
+
+size_t
+NYTP_write_src_line(handle, fid, line, text)
+NYTP_file handle
+unsigned int fid
+unsigned int line
+SV *text
+ PREINIT:
+ STRLEN len;
+ const char *const p = SvPV(text, len);
+ CODE:
+ RETVAL = NYTP_write_src_line(handle, fid, line,
+ p, SvUTF8(text) ? -(I32)len :
(I32)len);
+ OUTPUT:
+ RETVAL
=======================================
--- /trunk/NYTProf.xs Mon Mar 8 01:47:23 2010
+++ /trunk/NYTProf.xs Mon Mar 8 01:47:36 2010
@@ -3378,9 +3378,7 @@
const char *src = (svp) ? SvPV(*svp, len) : "";
/* outputting the tag and fid for each (non empty) line
* is a little inefficient, but not enough to worry about */
- output_tag_int(out, NYTP_TAG_SRC_LINE, e->id);
- output_int(out, line);
- output_str(out, src, (I32)len); /* includes newline */
+ NYTP_write_src_line(out, e->id, line, src, (I32)len); /*
includes newline */
if (trace_level >= 5) {
logwarn("fid %d src line %d: %s%s", e->id, line, src,
(len && src[len-1]=='\n') ? "" : "\n");
=======================================
--- /trunk/bin/nytprofmerge Mon Mar 8 01:47:29 2010
+++ /trunk/bin/nytprofmerge Mon Mar 8 01:47:36 2010
@@ -201,9 +201,7 @@
# Is this a subroutine (re)defined in an eval?
my $mapped_fid = $map_range{$fid}[$line];
$fid = $mapped_fid if defined $mapped_fid;
- $out->write('S');
- $out->output_int($fid, $line);
- $out->output_str($text);
+ $out->write_src_line($fid, $line, $text);
},
);
--
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]