From e38f0a5617e184860da35759ebb089dc29fa7230 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 11 Feb 2010 09:48:27 +0000 Subject: [PATCH] Abstract writing process end into NYTP_write_process_end(). Add a wrapper for it and use it from nytprofmerge. --- FileHandle.h | 2 ++ FileHandle.xs | 23 +++++++++++++++++++++++ NYTProf.xs | 3 +-- bin/nytprofmerge | 4 +--- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/FileHandle.h b/FileHandle.h index dc829ae..ef71a11 100644 --- a/FileHandle.h +++ b/FileHandle.h @@ -70,3 +70,5 @@ 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); +size_t NYTP_write_process_end(NYTP_file ofile, unsigned int pid, + NV time_of_day); diff --git a/FileHandle.xs b/FileHandle.xs index dcfb76b..7712ca1 100644 --- a/FileHandle.xs +++ b/FileHandle.xs @@ -731,6 +731,23 @@ NYTP_write_process_start(NYTP_file ofile, unsigned int pid, unsigned int ppid, return total; } +size_t +NYTP_write_process_end(NYTP_file ofile, unsigned int pid, NV time_of_day) +{ + size_t total; + size_t retval; + + total = retval = output_tag_int(ofile, NYTP_TAG_PID_END, pid); + 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_ @@ -857,3 +874,9 @@ NYTP_file handle unsigned int pid unsigned int ppid NV time_of_day + +size_t +NYTP_write_process_end(handle, pid, time_of_day) +NYTP_file handle +unsigned int pid +NV time_of_day diff --git a/NYTProf.xs b/NYTProf.xs index 3926438..dfd24a6 100644 --- a/NYTProf.xs +++ b/NYTProf.xs @@ -1632,8 +1632,7 @@ close_output_file(pTHX) { /* mark end of profile data for last_pid pid * which is the pid that this file relates to */ - output_tag_int(out, NYTP_TAG_PID_END, last_pid); - output_nv(out, gettimeofday_nv()); + NYTP_write_process_end(out, last_pid, gettimeofday_nv()); if ((result = NYTP_close(out, 0))) logwarn("Error closing profile data file: %s\n", strerror(result)); diff --git a/bin/nytprofmerge b/bin/nytprofmerge index 30eac8b..12ff318 100755 --- a/bin/nytprofmerge +++ b/bin/nytprofmerge @@ -139,9 +139,7 @@ my %dispatcher = }, PID_END => sub { my (undef, $pid, $time) = @_; - $out->write('p'); - $out->output_int($pid); - $out->output_nv($time); + $out->write_process_end($pid, $time); }, NEW_FID => sub { -- 1.6.0