Bug 715953 - add telemetry for recent background timers; r=bz

This commit is contained in:
Nathan Froyd 2012-01-18 09:35:05 -08:00
parent e579af5a86
commit 8e520a8e46
2 changed files with 15 additions and 0 deletions

View File

@ -283,6 +283,9 @@ static bool gDragServiceDisabled = false;
static FILE *gDumpFile = nsnull;
static PRUint64 gNextWindowID = 0;
static PRUint32 gSerialCounter = 0;
static PRUint32 gTimeoutsRecentlySet = 0;
static TimeStamp gLastRecordedRecentTimeouts;
#define STATISTICS_INTERVAL (30 * PR_MSEC_PER_SEC)
#ifdef DEBUG_jst
PRInt32 gTimeoutCnt = 0;
@ -9054,6 +9057,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
timeout->mPrincipal = ourPrincipal;
}
++gTimeoutsRecentlySet;
TimeDuration delta = TimeDuration::FromMilliseconds(realInterval);
if (!IsFrozen() && !mTimeoutsSuspendDepth) {
@ -9228,6 +9232,16 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
return;
}
// Record telemetry information about timers set recently.
TimeDuration recordingInterval = TimeDuration::FromMilliseconds(STATISTICS_INTERVAL);
if (gLastRecordedRecentTimeouts.IsNull() ||
now - gLastRecordedRecentTimeouts > recordingInterval) {
PRUint32 count = gTimeoutsRecentlySet;
gTimeoutsRecentlySet = 0;
Telemetry::Accumulate(Telemetry::DOM_TIMERS_RECENTLY_SET, count);
gLastRecordedRecentTimeouts = now;
}
// Insert a dummy timeout into the list of timeouts between the
// portion of the list that we are about to process now and those
// timeouts that will be processed in a future call to

View File

@ -324,6 +324,7 @@ HISTOGRAM_BOOLEAN(XMLHTTPREQUEST_ASYNC_OR_SYNC, "Type of XMLHttpRequest, async o
* DOM telemetry.
*/
HISTOGRAM(DOM_TIMERS_FIRED_PER_NATIVE_TIMEOUT, 1, 3000, 10, EXPONENTIAL, "DOM: Timer handlers called per native timer expiration")
HISTOGRAM(DOM_TIMERS_RECENTLY_SET, 1, 3000, 10, EXPONENTIAL, "DOM: setTimeout/setInterval calls recently (last 30s or more)")
/**
* DOM Storage telemetry.