Bug 1496226 - Be sure raptor's capturing of first-contentful-paint in google chrome is the correct entry; r=jmaher
authorRob Wood <rwood@mozilla.com>
Mon, 15 Oct 2018 15:43:13 +0000
changeset 497053 e742cc754ebc1a989ab174e26ba29001fecfef7a
parent 497052 84ceb42728e4509c23f5167eb0ef166986efad4a
child 497054 ddd7b581697d9ccff863b6901ef9e01e5772b2e4
push id9996
push userarchaeopteryx@coole-files.de
push dateThu, 18 Oct 2018 18:37:15 +0000
treeherdermozilla-beta@8efe26839243 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1496226
milestone64.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 1496226 - Be sure raptor's capturing of first-contentful-paint in google chrome is the correct entry; r=jmaher Differential Revision: https://phabricator.services.mozilla.com/D8731
testing/raptor/webext/raptor/measure.js
--- a/testing/raptor/webext/raptor/measure.js
+++ b/testing/raptor/webext/raptor/measure.js
@@ -76,17 +76,17 @@ function setup(settings) {
       measureDCF();
     }
   }
 
   if (settings.measure.fcp !== undefined) {
     getFCP = settings.measure.fcp;
     if (getFCP) {
       console.log("will be measuring first-contentful-paint");
-      measureFirstContentfulPaint();
+      measureFCP();
     }
   }
 
   if (settings.measure.hero !== undefined) {
     if (settings.measure.hero.length !== 0) {
       getHero = true;
       heroesToCapture = settings.measure.hero;
       console.log("hero elements to measure: " + heroesToCapture);
@@ -219,38 +219,38 @@ function measureTTFI() {
       window.setTimeout(measureTTFI, 200);
     } else {
       // unable to get a value for TTFI - filter out later
       sendResult("ttfi", 0);
     }
   }
 }
 
-function measureFirstContentfulPaint() {
+function measureFCP() {
   // see https://developer.mozilla.org/en-US/docs/Web/API/PerformancePaintTiming
   var resultType = "fcp";
   var result = 0;
 
-  let performanceEntries = perfData.getEntriesByType("paint");
+  let perfEntries = perfData.getEntriesByType("paint");
 
-  if (performanceEntries.length >= 2) {
-    if (performanceEntries[1].startTime != undefined)
-      result = performanceEntries[1].startTime;
+  if (perfEntries.length >= 2) {
+    if (perfEntries[1].name == "first-contentful-paint" && perfEntries[1].startTime != undefined)
+      result = perfEntries[1].startTime;
   }
 
   if (result > 0) {
     console.log("got time to first-contentful-paint");
     sendResult(resultType, result);
     perfData.clearMarks();
     perfData.clearMeasures();
   } else {
     gRetryCounter += 1;
     if (gRetryCounter <= 10) {
       console.log("\ntime to first-contentful-paint is not yet available (0), retry number " + gRetryCounter + "...\n");
-      window.setTimeout(measureFirstContentfulPaint, 100);
+      window.setTimeout(measureFCP, 100);
     } else {
       console.log("\nunable to get a value for time-to-fcp after " + gRetryCounter + " retries\n");
     }
   }
 }
 
 function sendResult(_type, _value) {
   // send result back to background runner script