Revision: 1103
Author: [email protected]
Date: Mon Mar  8 01:46:15 2010
Log: Abstract writing process start into NYTP_write_process_start().

This requires moving the tag definitions from NYTProf.xs into a header file.
Once the abstraction is done, including input, it should be possible to move
them into FileHandle.xs.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1103

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

=======================================
--- /trunk/FileHandle.h Mon Mar  8 01:46:03 2010
+++ /trunk/FileHandle.h Mon Mar  8 01:46:15 2010
@@ -43,6 +43,21 @@
 #  define NYTP_type_of_offset(file) ""
 #endif

+#define NYTP_TAG_ATTRIBUTE       ':'    /* :name=value\n */
+#define NYTP_TAG_COMMENT         '#'    /* till newline */
+#define NYTP_TAG_TIME_BLOCK      '*'
+#define NYTP_TAG_TIME_LINE       '+'
+#define NYTP_TAG_DISCOUNT        '-'
+#define NYTP_TAG_NEW_FID         '@'
+#define NYTP_TAG_SRC_LINE        'S'    /* fid, line, str */
+#define NYTP_TAG_SUB_INFO        's'
+#define NYTP_TAG_SUB_CALLERS     'c'
+#define NYTP_TAG_PID_START       'P'
+#define NYTP_TAG_PID_END         'p'
+#define NYTP_TAG_STRING          '\''
+#define NYTP_TAG_STRING_UTF8     '"'
+#define NYTP_TAG_START_DEFLATE   'z'
+
 void NYTProf_croak_if_not_stdio(NYTP_file file, const char *function);

 size_t NYTP_write_comment(NYTP_file ofile, const char *format, ...);
@@ -53,3 +68,5 @@
                                    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_write_process_start(NYTP_file ofile, unsigned int pid,
+                                unsigned int ppid, NV time_of_day);
=======================================
--- /trunk/FileHandle.xs        Mon Mar  8 01:46:03 2010
+++ /trunk/FileHandle.xs        Mon Mar  8 01:46:15 2010
@@ -708,6 +708,28 @@

     return NYTP_write_attribute_string(ofile, key, key_len, buffer, len);
 }
+
+size_t
+NYTP_write_process_start(NYTP_file ofile, unsigned int pid, unsigned int ppid,
+                         NV time_of_day)
+{
+    size_t total;
+    size_t retval;
+
+    total = retval = output_tag_int(ofile, NYTP_TAG_PID_START, pid);
+    if (retval < 1)
+        return retval;
+
+    total += retval = output_int(ofile, ppid);
+    if (retval < 1)
+        return retval;
+
+    total += retval = output_nv(ofile, time_of_day);
+    if (retval < 1)
+        return retval;
+
+    return total;
+}


MODULE = Devel::NYTProf::FileHandle PACKAGE = Devel::NYTProf::FileHandle PREFIX = NYTP_
=======================================
--- /trunk/NYTProf.xs   Mon Mar  8 01:46:08 2010
+++ /trunk/NYTProf.xs   Mon Mar  8 01:46:15 2010
@@ -130,21 +130,6 @@
#define NYTP_FIDf_IS_ALIAS 0x0040 /* fid is clone of the 'parent' fid it was autosplit from */ #define NYTP_FIDf_IS_FAKE 0x0080 /* eg dummy caller of a string eval that doesn't have a filename */

-#define NYTP_TAG_ATTRIBUTE       ':'    /* :name=value\n */
-#define NYTP_TAG_COMMENT         '#'    /* till newline */
-#define NYTP_TAG_TIME_BLOCK      '*'
-#define NYTP_TAG_TIME_LINE       '+'
-#define NYTP_TAG_DISCOUNT        '-'
-#define NYTP_TAG_NEW_FID         '@'
-#define NYTP_TAG_SRC_LINE        'S'    /* fid, line, str */
-#define NYTP_TAG_SUB_INFO        's'
-#define NYTP_TAG_SUB_CALLERS     'c'
-#define NYTP_TAG_PID_START       'P'
-#define NYTP_TAG_PID_END         'p'
-#define NYTP_TAG_STRING          '\''
-#define NYTP_TAG_STRING_UTF8     '"'
-#define NYTP_TAG_START_DEFLATE   'z'
-
 /* indices to elements of the file info array */
 #define NYTP_FIDi_FILENAME      0
 #define NYTP_FIDi_EVAL_FID      1
@@ -474,10 +459,8 @@
         NYTP_start_deflate(out, compression_level);
     }
 #endif
-
-    output_tag_int(out, NYTP_TAG_PID_START, getpid());
-    output_int(out, getppid());
-    output_nv(out, gettimeofday_nv());
+
+    NYTP_write_process_start(out, getpid(), getppid(), gettimeofday_nv());

write_cached_fids(); /* empty initially, non-empty after fork */

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