Bug 1517272: Add top-level Document Load event markers for the profiler r=mstange
authorRandell Jesup <rjesup@jesup.org>
Tue, 15 Jan 2019 12:49:03 -0500
changeset 511119 e6d86c730d0acde5ca17f2a4d07a0ded5b0113b2
parent 511118 39104a14a66b345dece9d434494b806f2219c67c
child 511120 aa43ce6e3442f05ec14243a2f1311012bc6b51cb
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1517272
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1517272: Add top-level Document Load event markers for the profiler r=mstange
dom/base/nsDOMNavigationTiming.cpp
--- a/dom/base/nsDOMNavigationTiming.cpp
+++ b/dom/base/nsDOMNavigationTiming.cpp
@@ -143,16 +143,35 @@ void nsDOMNavigationTiming::NotifyLoadEv
     return;
   }
   mLoadEventEnd = TimeStamp::Now();
 
   PROFILER_TRACING_DOCSHELL("Navigation", "Load", TRACING_INTERVAL_END,
                             mDocShell);
 
   if (IsTopLevelContentDocumentInContentProcess()) {
+#ifdef MOZ_GECKO_PROFILER
+    if (profiler_is_active() || PAGELOAD_LOG_ENABLED()) {
+      TimeDuration elapsed = mLoadEventEnd - mNavigationStart;
+      TimeDuration duration = mLoadEventEnd - mLoadEventStart;
+      nsAutoCString spec;
+      if (mLoadedURI) {
+        mLoadedURI->GetSpec(spec);
+      }
+      nsPrintfCString marker(
+          "Document %s loaded after %dms, load event duration %dms", spec.get(),
+          int(elapsed.ToMilliseconds()), int(duration.ToMilliseconds()));
+      DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
+      PAGELOAD_LOG(("%s", marker.get()));
+      profiler_add_marker(
+          "DocumentLoad",
+          MakeUnique<TextMarkerPayload>(marker, mNavigationStart, mLoadEventEnd,
+                                        docShellId, docShellHistoryId));
+    }
+#endif
     Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_LOAD_EVENT_END_MS,
                                    mNavigationStart);
   }
 }
 
 void nsDOMNavigationTiming::SetDOMLoadingTimeStamp(nsIURI* aURI,
                                                    TimeStamp aValue) {
   if (!mDOMLoading.IsNull()) {