X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FProfHeap.c;h=49b38137918c36242f2bb220cc7e469ac9a5d352;hb=423d477bfecd490de1449c59325c8776f91d7aac;hp=1f0156c225a1795b578bb1f09677a3971f20a763;hpb=9b5e08861ad487e9221cb987d9c3f413399b5d37;p=ghc-hetmet.git diff --git a/ghc/rts/ProfHeap.c b/ghc/rts/ProfHeap.c index 1f0156c..49b3813 100644 --- a/ghc/rts/ProfHeap.c +++ b/ghc/rts/ProfHeap.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: ProfHeap.c,v 1.51 2004/03/19 23:20:20 panne Exp $ + * $Id: ProfHeap.c,v 1.53 2004/08/13 13:10:25 simonmar Exp $ * * (c) The GHC Team, 1998-2003 * @@ -32,6 +32,7 @@ #include #include +#include /* ----------------------------------------------------------------------------- * era stores the current time period. It is the same as the @@ -249,6 +250,7 @@ LDV_recordDead( StgClosure *c, nat size ) if (era > 0 && closureSatisfiesConstraints(c)) { size -= sizeofW(StgProfHeader); + ASSERT(LDVW(c) != 0); if ((LDVW((c)) & LDV_STATE_MASK) == LDV_STATE_CREATE) { t = (LDVW((c)) & LDV_CREATE_MASK) >> LDV_SHIFT; if (t < era) { @@ -382,6 +384,16 @@ void endProfiling( void ) } #endif /* DEBUG_HEAP_PROF */ +static void +printSample(rtsBool beginSample, StgDouble sampleValue) +{ + StgDouble fractionalPart, integralPart; + fractionalPart = modf(sampleValue, &integralPart); + fprintf(hp_file, "%s %d.%02d\n", + (beginSample ? "BEGIN_SAMPLE" : "END_SAMPLE"), + (int)integralPart, (int)(fractionalPart * 100 + 0.5)); +} + /* -------------------------------------------------------------------------- * Initialize the heap profilier * ----------------------------------------------------------------------- */ @@ -443,8 +455,8 @@ initHeapProfiling(void) fprintf(hp_file, "SAMPLE_UNIT \"seconds\"\n"); fprintf(hp_file, "VALUE_UNIT \"bytes\"\n"); - fprintf(hp_file, "BEGIN_SAMPLE 0.00\n"); - fprintf(hp_file, "END_SAMPLE 0.00\n"); + printSample(rtsTrue, 0); + printSample(rtsFalse, 0); #ifdef DEBUG_HEAP_PROF DEBUG_LoadSymbols(prog_name); @@ -486,8 +498,8 @@ endHeapProfiling(void) #endif seconds = mut_user_time(); - fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", seconds); - fprintf(hp_file, "END_SAMPLE %0.2f\n", seconds); + printSample(rtsTrue, seconds); + printSample(rtsFalse, seconds); fclose(hp_file); } @@ -583,6 +595,7 @@ rtsBool closureSatisfiesConstraints( StgClosure* p ) { #ifdef DEBUG_HEAP_PROF + (void)p; /* keep gcc -Wall happy */ return rtsTrue; #else rtsBool b; @@ -729,7 +742,7 @@ dumpCensus( Census *census ) counter *ctr; int count; - fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", census->time); + printSample(rtsTrue, census->time); #ifdef PROFILING if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_LDV) { @@ -742,7 +755,7 @@ dumpCensus( Census *census ) census->prim * sizeof(W_)); fprintf(hp_file, "DRAG\t%u\n", census->drag_total * sizeof(W_)); - fprintf(hp_file, "END_SAMPLE %0.2f\n", census->time); + printSample(rtsFalse, census->time); return; } #endif @@ -822,7 +835,7 @@ dumpCensus( Census *census ) fprintf(hp_file, "\t%d\n", count * sizeof(W_)); } - fprintf(hp_file, "END_SAMPLE %0.2f\n", census->time); + printSample(rtsFalse, census->time); } /* -----------------------------------------------------------------------------