X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FProfiling.c;h=d729c8a09e5fff16d291a8f220cf34a796df005b;hp=33301a91c1ce84804a91968dd59546cbd9e59d9c;hb=b19ba85c6ec3504a66b33243cfb43599d8c298a7;hpb=5a2769f0273dd389977e8283375e7920d183bdd4 diff --git a/rts/Profiling.c b/rts/Profiling.c index 33301a9..d729c8a 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -13,7 +13,6 @@ #include "RtsUtils.h" #include "RtsFlags.h" #include "Profiling.h" -#include "Storage.h" #include "Proftimer.h" #include "Timer.h" #include "ProfHeap.h" @@ -23,6 +22,10 @@ #include +#ifdef DEBUG +#include "Trace.h" +#endif + /* * Profiling allocation arena. */ @@ -183,6 +186,12 @@ initProfiling1 (void) } void +freeProfiling1 (void) +{ + arenaFree(prof_arena); +} + +void initProfiling2 (void) { CostCentreStack *ccs, *next; @@ -259,41 +268,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", TICK_MILLISECS); - - /* 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", @@ -732,8 +766,10 @@ reportCCSProfiling( void ) fprintf(prof_file, "\n\n"); fprintf(prof_file, "\ttotal time = %11.2f secs (%lu ticks @ %d ms)\n", - total_prof_ticks / (StgFloat) TICK_FREQUENCY, - total_prof_ticks, TICK_MILLISECS); + (double) total_prof_ticks * + (double) RtsFlags.MiscFlags.tickInterval / 1000, + (unsigned long) total_prof_ticks, + (int) RtsFlags.MiscFlags.tickInterval); fprintf(prof_file, "\ttotal alloc = %11s bytes", ullong_format_string(total_alloc * sizeof(W_), @@ -882,8 +918,6 @@ gen_XML_logfile( void ) reportCCS_XML(pruneCCSTree(CCS_MAIN)); fprintf(prof_file, " 0\n"); - - fclose(prof_file); } static void