Bug 1239750 - Add DAMP measurement for rAF performance during streaming console.log messages;r=fitzgen draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 20 Jan 2016 11:38:37 -0800
changeset 323624 b640a58d7a02
parent 323623 bcb2eae790e6
child 513244 cfc80fe92d64
push id9754
push userbgrinstead@mozilla.com
push date2016-01-20 19:38 +0000
reviewersfitzgen
bugs1239750
milestone46.0a1
Bug 1239750 - Add DAMP measurement for rAF performance during streaming console.log messages;r=fitzgen
testing/talos/talos/tests/devtools/addon/content/damp.html
testing/talos/talos/tests/devtools/addon/content/damp.js
--- a/testing/talos/talos/tests/devtools/addon/content/damp.html
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.html
@@ -13,28 +13,30 @@ var defaultConfig = {
     webconsoleOpen: true,
     inspectorOpen: true,
     debuggerOpen: true,
     styleEditorOpen: true,
     performanceOpen: true,
     netmonitorOpen: true,
     saveAndReadHeapSnapshot: true,
     consoleBulkLogging: true,
+    consoleStreamLogging: true,
   }
 };
 
 var testsInfo = {
   webconsoleOpen: "Measure open/close toolbox on webconsole panel",
   inspectorOpen: "Measure open/close toolbox on inspector panel",
   debuggerOpen: "Measure open/close toolbox on debugger panel",
   styleEditorOpen: "Measure open/close toolbox on style editor panel",
   performanceOpen: "Measure open/close toolbox on performance panel",
   netmonitorOpen: "Measure open/close toolbox on network monitor panel",
   saveAndReadHeapSnapshot: "Measure open/close toolbox on memory panel and save/read heap snapshot",
   consoleBulkLogging: "Measure time for a bunch of sync console.log statements to appear",
+  consoleStreamLogging: "Measure rAF on page during a stream of console.log statements",
 };
 
 function updateConfig() {
   config = {subtests: []};
   for (var test in defaultConfig.subtests) {
     if ($("subtest-" + test).checked) {
       config.subtests.push(test);
     }
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -152,16 +152,66 @@ Damp.prototype = {
       name: "console.bulklog",
       value: end - start
     });
 
     yield this.closeToolbox(null);
     yield this.testTeardown();
   }),
 
+  // Log a stream of console messages, 1 per rAF.  Then record the average
+  // time per rAF.  The idea is that the console being slow can slow down
+  // content (i.e. Bug 1237368).
+  _consoleStreamLoggingTest: Task.async(function*() {
+    let TOTAL_MESSAGES = 100;
+    let tab = yield this.testSetup(SIMPLE_URL);
+    let messageManager = tab.linkedBrowser.messageManager;
+    let {toolbox} = yield this.openToolbox("webconsole");
+    let webconsole = toolbox.getPanel("webconsole");
+
+    // Load a frame script using a data URI so we can do logs
+    // from the page.  So this is running in content.
+    messageManager.loadFrameScript("data:,(" + encodeURIComponent(
+      `function () {
+        let count = 0;
+        let startTime = content.performance.now();
+        function log() {
+          if (++count < ${TOTAL_MESSAGES}) {
+            content.document.querySelector("h1").textContent += count + "\\n";
+            content.console.log('damp', count,
+                                content,
+                                content.document,
+                                content.document.body,
+                                content.document.documentElement,
+                                new Array(100).join(" DAMP? DAMP! "));
+            content.requestAnimationFrame(log);
+          } else {
+            let avgTime = (content.performance.now() - startTime) / ${TOTAL_MESSAGES};
+            sendSyncMessage("done", Math.round(avgTime));
+          }
+        }
+        log();
+      }`
+    ) + ")()", true);
+
+    let avgTime = yield new Promise(resolve => {
+      messageManager.addMessageListener("done", (e) => {
+        resolve(e.data);
+      });
+    });
+
+    this._results.push({
+      name: "console.streamlog",
+      value: avgTime
+    });
+
+    yield this.closeToolbox(null);
+    yield this.testTeardown();
+  }),
+
   takeCensus: function(label) {
     let start = performance.now();
 
     this._snapshot.takeCensus({
       breakdown: {
         by: "coarseType",
         objects: {
           by: "objectClass",
@@ -375,11 +425,14 @@ Damp.prototype = {
 
     let tests = [];
     tests = tests.concat(this._getToolLoadingTests(SIMPLE_URL, "simple"));
     tests = tests.concat(this._getToolLoadingTests(COMPLICATED_URL, "complicated"));
 
     if (config.subtests.indexOf("consoleBulkLogging") > -1) {
       tests = tests.concat(this._consoleBulkLoggingTest);
     }
+    if (config.subtests.indexOf("consoleStreamLogging") > -1) {
+      tests = tests.concat(this._consoleStreamLoggingTest);
+    }
     this._doSequence(tests, this._doneInternal);
   }
 }