From 084b46b0d0d8e6e47df0882d8cbc301b53211bb8 Mon Sep 17 00:00:00 2001 From: Taras Glek Date: Thu, 12 May 2011 11:22:25 -0700 Subject: [PATCH] bug 585196: Cycle-collector telemetry probe r=bent --- xpcom/base/nsCycleCollector.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index ea1529c3446..4700bb6ae39 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -125,6 +125,7 @@ #endif #endif +#include "base/basictypes.h" #include "nsCycleCollectionParticipant.h" #include "nsCycleCollectorUtils.h" #include "nsIProgrammingLanguage.h" @@ -151,7 +152,8 @@ #include "nsIXPConnect.h" #include "nsIJSRuntimeService.h" #include "xpcpublic.h" - +#include "base/histogram.h" +#include "base/logging.h" #include #include #ifdef WIN32 @@ -981,7 +983,7 @@ struct nsCycleCollector PRBool mFollowupCollection; PRUint32 mCollectedObjects; PRBool mFirstCollection; - PRTime mCollectionStart; + TimeStamp mCollectionStart; nsCycleCollectionLanguageRuntime *mRuntimes[nsIProgrammingLanguage::MAX+1]; nsCycleCollectionXPCOMRuntime mXPCOMRuntime; @@ -2477,8 +2479,8 @@ nsCycleCollector::PrepareForCollection(nsTPtrArray *aWhiteNodes) #ifdef COLLECT_TIME_DEBUG printf("cc: nsCycleCollector::PrepareForCollection()\n"); - mCollectionStart = PR_Now(); #endif + mCollectionStart = TimeStamp::Now(); mCollectionInProgress = PR_TRUE; @@ -2508,10 +2510,13 @@ nsCycleCollector::CleanupAfterCollection() _heapmin(); #endif + PRUint32 interval((TimeStamp::Now() - mCollectionStart).ToMilliseconds()); #ifdef COLLECT_TIME_DEBUG - printf("cc: CleanupAfterCollection(), total time %lldms\n", - (PR_Now() - mCollectionStart) / PR_USEC_PER_MSEC); + printf("cc: CleanupAfterCollection(), total time %ums\n", interval); #endif + UMA_HISTOGRAM_TIMES("nsCycleCollector::Collect (ms)", + base::TimeDelta::FromMilliseconds(interval)); + #ifdef DEBUG_CC ExplainLiveExpectedGarbage(); #endif