From 929d827c8be1e995d9e7049dc875362f6bb43145 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 23 Sep 2011 14:30:49 +0200 Subject: [PATCH] Bug 686435 - Add a telemetry probe on nsAppShellService::CreateTopLevelWindow. r=taras --- toolkit/components/startup/nsAppStartup.cpp | 11 ++++++++++- toolkit/components/telemetry/TelemetryHistograms.h | 2 +- xpfe/appshell/src/nsAppShellService.cpp | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index ae6f4e0a836..a5f71255e1e 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -100,6 +100,9 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); using namespace mozilla; extern PRTime gXRE_mainTimestamp; +// The following tracks our overhead between reaching XRE_main and loading any XUL +extern PRTime gCreateTopLevelWindowTimestamp;// Timestamp of the first call to + // nsAppShellService::CreateTopLevelWindow extern PRTime gFirstPaintTimestamp; // mfinklesessionstore-browser-state-restored might be a better choice than the one below static PRTime gRestoredTimestamp = 0; // Timestamp of sessionstore-windows-restored @@ -713,7 +716,8 @@ enum { INVALID_PROCESS_CREATION = 0, INVALID_MAIN, INVALID_FIRST_PAINT, - INVALID_SESSION_RESTORED + INVALID_SESSION_RESTORED, + INVALID_CREATE_TOP_LEVEL_WINDOW }; NS_IMETHODIMP @@ -763,6 +767,11 @@ nsAppStartup::GetStartupInfo() else Telemetry::Accumulate(Telemetry::STARTUP_MEASUREMENT_ERRORS, INVALID_MAIN); + if (gCreateTopLevelWindowTimestamp >= gProcessCreationTimestamp) + MaybeDefineProperty(cx, obj, "createTopLevelWindow", gCreateTopLevelWindowTimestamp); + else + Telemetry::Accumulate(Telemetry::STARTUP_MEASUREMENT_ERRORS, INVALID_CREATE_TOP_LEVEL_WINDOW); + if (gFirstPaintTimestamp >= gXRE_mainTimestamp) MaybeDefineProperty(cx, obj, "firstPaint", gFirstPaintTimestamp); else diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 47f332fc047..a696161c140 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -174,7 +174,7 @@ HISTOGRAM(MOZ_SQLITE_PLACES_WRITE_B, 1, 32768, 3, LINEAR, "SQLite write (bytes)" HISTOGRAM(MOZ_SQLITE_COOKIES_WRITE_B, 1, 32768, 3, LINEAR, "SQLite write (bytes)") HISTOGRAM(MOZ_SQLITE_URLCLASSIFIER_WRITE_B, 1, 32768, 3, LINEAR, "SQLite write (bytes)") HISTOGRAM(MOZ_SQLITE_OTHER_WRITE_B, 1, 32768, 3, LINEAR, "SQLite write (bytes)") -HISTOGRAM(STARTUP_MEASUREMENT_ERRORS, 1, 3, 4, LINEAR, "Flags errors in startup calculation()") +HISTOGRAM(STARTUP_MEASUREMENT_ERRORS, 1, 4, 5, LINEAR, "Flags errors in startup calculation()") HISTOGRAM(NETWORK_DISK_CACHE_OPEN, 1, 10000, 10, EXPONENTIAL, "Time spent opening disk cache (ms)") HISTOGRAM(NETWORK_DISK_CACHE_TRASHRENAME, 1, 10000, 10, EXPONENTIAL, "Time spent renaming bad Cache to Cache.Trash (ms)") HISTOGRAM(NETWORK_DISK_CACHE_DELETEDIR, 1, 10000, 10, EXPONENTIAL, "Time spent deleting disk cache (ms)") diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 0c943f59b68..a9acbd7896a 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -156,6 +156,8 @@ nsAppShellService::DestroyHiddenWindow() return NS_OK; } +PRTime gCreateTopLevelWindowTimestamp = 0; + /* * Create a new top level window and display the given URL within it... */ @@ -171,6 +173,9 @@ nsAppShellService::CreateTopLevelWindow(nsIXULWindow *aParent, { nsresult rv; + if (!gCreateTopLevelWindowTimestamp) + gCreateTopLevelWindowTimestamp = PR_Now(); + nsWebShellWindow *newWindow = nsnull; rv = JustCreateTopWindow(aParent, aUrl, aChromeMask, aInitialWidth, aInitialHeight,