X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FProfiling.c;h=6d23bc2fe260c84d8e8a367984c7a82e26c8e3e7;hb=fff1f6194c3c39de53cd645bda9865fb131b1c68;hp=4e759b6942a85ba7d618d3ebc01e89e4859a71bb;hpb=ed12b7043fa98928f75c289a756fbcef546315f8;p=ghc-hetmet.git diff --git a/rts/Profiling.c b/rts/Profiling.c index 4e759b6..6d23bc2 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -10,15 +10,13 @@ #include "PosixSource.h" #include "Rts.h" + #include "RtsUtils.h" -#include "RtsFlags.h" #include "Profiling.h" #include "Proftimer.h" -#include "Timer.h" #include "ProfHeap.h" #include "Arena.h" #include "RetainerProfile.h" -#include "LdvProfile.h" #include @@ -42,7 +40,7 @@ unsigned int HP_ID; /* figures for the profiling report. */ -static ullong total_alloc; +static StgWord64 total_alloc; static lnat total_prof_ticks; /* Globals for opening the profiling log file(s) @@ -268,41 +266,66 @@ ccsSetSelected( CostCentreStack *ccs ) static void initProfilingLogFile(void) { - /* Initialise the log file name */ - prof_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6); - sprintf(prof_filename, "%s.prof", prog_name); - - /* open the log file */ - if ((prof_file = fopen(prof_filename, "w")) == NULL) { - debugBelch("Can't open profiling report file %s\n", prof_filename); - RtsFlags.CcFlags.doCostCentres = 0; - // The following line was added by Sung; retainer/LDV profiling may need - // two output files, i.e., .prof/hp. - if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER) - RtsFlags.ProfFlags.doHeapProfile = 0; - return; + char *prog; + + prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + strcpy(prog, prog_name); +#ifdef mingw32_HOST_OS + // on Windows, drop the .exe suffix if there is one + { + char *suff; + suff = strrchr(prog,'.'); + if (suff != NULL && !strcmp(suff,".exe")) { + *suff = '\0'; + } } +#endif - if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) { - /* dump the time, and the profiling interval */ - fprintf(prof_file, "\"%s\"\n", time_str()); - fprintf(prof_file, "\"%d ms\"\n", RtsFlags.MiscFlags.tickInterval); - - /* declare all the cost centres */ - { - CostCentre *cc; - for (cc = CC_LIST; cc != NULL; cc = cc->link) { - fprintf(prof_file, "%d %ld \"%s\" \"%s\"\n", - CC_UQ, cc->ccID, cc->label, cc->module); - } - } + if (RtsFlags.CcFlags.doCostCentres == 0 && + RtsFlags.ProfFlags.doHeapProfile != HEAP_BY_RETAINER) + { + /* No need for the .prof file */ + prof_filename = NULL; + prof_file = NULL; + } + else + { + /* Initialise the log file name */ + prof_filename = arenaAlloc(prof_arena, strlen(prog) + 6); + sprintf(prof_filename, "%s.prof", prog); + + /* open the log file */ + if ((prof_file = fopen(prof_filename, "w")) == NULL) { + debugBelch("Can't open profiling report file %s\n", prof_filename); + RtsFlags.CcFlags.doCostCentres = 0; + // The following line was added by Sung; retainer/LDV profiling may need + // two output files, i.e., .prof/hp. + if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER) + RtsFlags.ProfFlags.doHeapProfile = 0; + return; + } + + if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) { + /* dump the time, and the profiling interval */ + fprintf(prof_file, "\"%s\"\n", time_str()); + fprintf(prof_file, "\"%d ms\"\n", RtsFlags.MiscFlags.tickInterval); + + /* declare all the cost centres */ + { + CostCentre *cc; + for (cc = CC_LIST; cc != NULL; cc = cc->link) { + fprintf(prof_file, "%d %ld \"%s\" \"%s\"\n", + CC_UQ, cc->ccID, cc->label, cc->module); + } + } + } } if (RtsFlags.ProfFlags.doHeapProfile) { /* Initialise the log file name */ - hp_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6); - sprintf(hp_filename, "%s.hp", prog_name); - + hp_filename = arenaAlloc(prof_arena, strlen(prog) + 6); + sprintf(hp_filename, "%s.hp", prog); + /* open the log file */ if ((hp_file = fopen(hp_filename, "w")) == NULL) { debugBelch("Can't open profiling report file %s\n", @@ -674,7 +697,7 @@ report_per_cc_costs( void ) if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) { fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64, - (StgWord64)(cc->time_ticks), cc->mem_alloc); + (StgWord64)(cc->time_ticks), cc->mem_alloc*sizeof(W_)); } fprintf(prof_file, "\n"); } @@ -747,7 +770,7 @@ reportCCSProfiling( void ) (int) RtsFlags.MiscFlags.tickInterval); fprintf(prof_file, "\ttotal alloc = %11s bytes", - ullong_format_string(total_alloc * sizeof(W_), + showStgWord64(total_alloc * sizeof(W_), temp, rtsTrue/*commas*/)); #if defined(PROFILING_DETAIL_COUNTS)