From 8e6e4cf6e5d7015bffd12af15862dea6513d6b01 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 11 Feb 2010 14:44:03 +0000 Subject: [PATCH] Abstract writing sub caller info into NYTP_write_sub_callers(). --- FileHandle.h | 7 ++++++ FileHandle.xs | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NYTProf.xs | 21 +++++++++---------- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/FileHandle.h b/FileHandle.h index f8358e0..572d6c1 100644 --- a/FileHandle.h +++ b/FileHandle.h @@ -85,3 +85,10 @@ size_t NYTP_write_time_line(NYTP_file ofile, unsigned int elapsed, 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 NYTP_write_sub_callers(NYTP_file ofile, unsigned int fid, + unsigned int line, + const char *caller_name, I32 caller_name_len, + unsigned int count, NV incl_rtime, NV excl_rtime, + NV incl_utime, NV incl_stime, NV reci_rtime, + unsigned int depth, + const char *called_name, I32 called_name_len); diff --git a/FileHandle.xs b/FileHandle.xs index 92d0244..dd31a3b 100644 --- a/FileHandle.xs +++ b/FileHandle.xs @@ -874,6 +874,64 @@ NYTP_write_sub_info(NYTP_file ofile, unsigned int fid, return total; } +size_t +NYTP_write_sub_callers(NYTP_file ofile, unsigned int fid, unsigned int line, + const char *caller_name, I32 caller_name_len, + unsigned int count, NV incl_rtime, NV excl_rtime, + NV incl_utime, NV incl_stime, NV reci_rtime, + unsigned int depth, + const char *called_name, I32 called_name_len) +{ + size_t total; + size_t retval; + + total = retval = output_tag_int(ofile, NYTP_TAG_SUB_CALLERS, fid); + if (retval < 1) + return retval; + + total += retval = output_int(ofile, line); + if (retval < 1) + return retval; + + total += retval = output_str(ofile, caller_name, caller_name_len); + if (retval < 1) + return retval; + + total += retval = output_int(ofile, count); + if (retval < 1) + return retval; + + total += retval = output_nv(ofile, incl_rtime); + if (retval < 1) + return retval; + + total += retval = output_nv(ofile, excl_rtime); + if (retval < 1) + return retval; + + total += retval = output_nv(ofile, incl_utime); + if (retval < 1) + return retval; + + total += retval = output_nv(ofile, incl_stime); + if (retval < 1) + return retval; + + total += retval = output_nv(ofile, reci_rtime); + if (retval < 1) + return retval; + + total += retval = output_int(ofile, depth); + if (retval < 1) + return retval; + + total += retval = output_str(ofile, called_name, called_name_len); + if (retval < 1) + return retval; + + return total; +} + MODULE = Devel::NYTProf::FileHandle PACKAGE = Devel::NYTProf::FileHandle PREFIX = NYTP_ PROTOTYPES: DISABLE diff --git a/NYTProf.xs b/NYTProf.xs index 20de22d..d1de9cc 100644 --- a/NYTProf.xs +++ b/NYTProf.xs @@ -3254,17 +3254,16 @@ write_sub_callers(pTHX) depth = uv_from_av(aTHX_ av, NYTP_SCi_REC_DEPTH , 0); sc[NYTP_SCi_REC_DEPTH] = depth * 1.0; - output_tag_int(out, NYTP_TAG_SUB_CALLERS, fid); - output_int(out, line); - output_str(out, caller_subname, caller_subname_len); - output_int(out, count); - output_nv(out, sc[NYTP_SCi_INCL_RTIME]); - output_nv(out, sc[NYTP_SCi_EXCL_RTIME]); - output_nv(out, sc[NYTP_SCi_INCL_UTIME]); - output_nv(out, sc[NYTP_SCi_INCL_STIME]); - output_nv(out, sc[NYTP_SCi_RECI_RTIME]); - output_int(out, depth); - output_str(out, called_subname, called_subname_len); + NYTP_write_sub_callers(out, fid, line, + caller_subname, caller_subname_len, + count, + sc[NYTP_SCi_INCL_RTIME], + sc[NYTP_SCi_EXCL_RTIME], + sc[NYTP_SCi_INCL_UTIME], + sc[NYTP_SCi_INCL_STIME], + sc[NYTP_SCi_RECI_RTIME], + depth, + called_subname, called_subname_len); /* sanity check - early warning */ if (sc[NYTP_SCi_INCL_RTIME] < 0.0 || sc[NYTP_SCi_EXCL_RTIME] < 0.0) { -- 1.6.0