Revision: 1119
Author: [email protected]
Date: Mon Mar  8 01:48:07 2010
Log: Add NYTP_start_deflate_write_tag_comment(), which abstracts writing out the
comment with the compression details (only available in the XS code), the
"start compression" tag, and starts compression. Use this from nytprofmerge,
which removes the finale $out->write(...) call. Now the output file format is
completely wrapped in XS.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1119

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

=======================================
--- /trunk/FileHandle.h Mon Mar  8 01:48:00 2010
+++ /trunk/FileHandle.h Mon Mar  8 01:48:07 2010
@@ -70,6 +70,7 @@
                                    size_t key_len, long value);
 size_t NYTP_write_attribute_unsigned(NYTP_file ofile, const char *key,
                                      size_t key_len, unsigned long value);
+size_t NYTP_start_deflate_write_tag_comment(NYTP_file ofile, int compression_level);
 size_t NYTP_write_process_start(NYTP_file ofile, unsigned int pid,
                                 unsigned int ppid, NV time_of_day);
 size_t NYTP_write_process_end(NYTP_file ofile, unsigned int pid,
=======================================
--- /trunk/FileHandle.xs        Mon Mar  8 01:48:00 2010
+++ /trunk/FileHandle.xs        Mon Mar  8 01:48:07 2010
@@ -795,6 +795,27 @@

     return NYTP_write_attribute_string(ofile, key, key_len, buffer, len);
 }
+
+size_t
+NYTP_start_deflate_write_tag_comment(NYTP_file ofile, int compression_level) {
+    const unsigned char tag = NYTP_TAG_START_DEFLATE;
+    size_t total;
+    size_t retval;
+
+ total = retval = NYTP_write_comment(ofile, "Compressed at level %d with zlib %s",
+                                        compression_level, zlibVersion());
+
+    if (retval < 1)
+        return retval;
+
+    total += retval = NYTP_write(ofile, &tag, sizeof(tag));
+    if (retval < 1)
+        return retval;
+
+    NYTP_start_deflate(ofile, compression_level);
+
+    return total;
+}

 size_t
NYTP_write_process_start(NYTP_file ofile, unsigned int pid, unsigned int ppid,
@@ -1142,6 +1163,11 @@
 NYTP_file handle
 int compression_level

+void
+NYTP_start_deflate_write_tag_comment(handle, compression_level = 6)
+NYTP_file handle
+int compression_level
+
 #endif

 int
=======================================
--- /trunk/NYTProf.xs   Mon Mar  8 01:48:00 2010
+++ /trunk/NYTProf.xs   Mon Mar  8 01:48:07 2010
@@ -452,11 +452,7 @@

 #ifdef HAS_ZLIB
     if (compression_level) {
-        const unsigned char tag = NYTP_TAG_START_DEFLATE;
-        NYTP_write_comment(out, "Compressed at level %d with zlib %s",
-                           compression_level, zlibVersion());
-        NYTP_write(out, &tag, sizeof(tag));
-        NYTP_start_deflate(out, compression_level);
+        NYTP_start_deflate_write_tag_comment(out, compression_level);
     }
 #endif

=======================================
--- /trunk/bin/nytprofmerge     Mon Mar  8 01:48:00 2010
+++ /trunk/bin/nytprofmerge     Mon Mar  8 01:48:07 2010
@@ -125,9 +125,8 @@
      },

      START_DEFLATE => sub {
-        if (!$deflating && $out->can('start_deflate')) {
-            $out->write('z');
-            $out->start_deflate;
+        if (!$deflating && $out->can('start_deflate_write_tag_comment')) {
+            $out->start_deflate_write_tag_comment;
             ++$deflating;
         }
      },

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