Bug 695213 - Add total time to MOZ_GCTIMER output.

This commit is contained in:
Bill McCloskey 2011-10-18 14:03:51 -07:00
parent e9e02c73ec
commit 52c3cb2132
2 changed files with 25 additions and 2 deletions

View File

@ -77,15 +77,27 @@ Statistics::Statistics(JSRuntime *rt)
}
PodArrayZero(counts);
PodArrayZero(totals);
startupTime = PRMJ_Now();
}
Statistics::~Statistics()
{
if (fp && fp != stdout && fp != stderr)
if (fp) {
if (fullFormat)
fprintf(fp,
"------>TOTAL "
"%6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %6.1f\n",
total(PHASE_GC), total(PHASE_MARK), total(PHASE_SWEEP),
total(PHASE_SWEEP_OBJECT), total(PHASE_SWEEP_STRING),
total(PHASE_SWEEP_SCRIPT), total(PHASE_SWEEP_SHAPE),
total(PHASE_DESTROY));
if (fp != stdout && fp != stderr)
fclose(fp);
}
}
struct GCCrashData
{
@ -119,6 +131,12 @@ Statistics::t(Phase phase)
return double(phaseTimes[phase]) / PRMJ_USEC_PER_MSEC;
}
double
Statistics::total(Phase phase)
{
return double(totals[phase]) / PRMJ_USEC_PER_MSEC;
}
double
Statistics::beginDelay(Phase phase1, Phase phase2)
{
@ -163,6 +181,9 @@ Statistics::endGC()
endPhase(PHASE_GC);
crash::SnapshotGCStack();
for (int i = 0; i < PHASE_LIMIT; i++)
totals[i] += phaseTimes[i];
if (JSAccumulateTelemetryDataCallback cb = runtime->telemetryCallback) {
(*cb)(JS_TELEMETRY_GC_REASON, triggerReason);
(*cb)(JS_TELEMETRY_GC_IS_COMPARTMENTAL, compartment ? 1 : 0);

View File

@ -125,9 +125,11 @@ struct Statistics {
uint64 phaseStarts[PHASE_LIMIT];
uint64 phaseEnds[PHASE_LIMIT];
uint64 phaseTimes[PHASE_LIMIT];
uint64 totals[PHASE_LIMIT];
unsigned int counts[STAT_LIMIT];
double t(Phase phase);
double total(Phase phase);
double beginDelay(Phase phase1, Phase phase2);
double endDelay(Phase phase1, Phase phase2);
void printStats();