/* -----------------------------------------------------------------------------
- * $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
*
#include <string.h>
#include <stdlib.h>
+#include <math.h>
/* -----------------------------------------------------------------------------
* era stores the current time period. It is the same as the
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) {
}
#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
* ----------------------------------------------------------------------- */
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);
#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);
}
closureSatisfiesConstraints( StgClosure* p )
{
#ifdef DEBUG_HEAP_PROF
+ (void)p; /* keep gcc -Wall happy */
return rtsTrue;
#else
rtsBool b;
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) {
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
fprintf(hp_file, "\t%d\n", count * sizeof(W_));
}
- fprintf(hp_file, "END_SAMPLE %0.2f\n", census->time);
+ printSample(rtsFalse, census->time);
}
/* -----------------------------------------------------------------------------