Bug 1239750 - Add DAMP measurement for rAF performance during streaming console.log messages;r=fitzgen draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Fri, 15 Jan 2016 10:16:39 -0800
changeset 322067 d30c296c04ea5a51dfff9ed1c672778ad7071ce7
parent 322066 ff9767245bdd26d0b0d0af7f7ecee66de0f885e4
child 513028 4685b40b0b18f11c9653f7da8c79ee0985fee322
push id9525
push userbgrinstead@mozilla.com
push dateFri, 15 Jan 2016 18:16:46 +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
@@ -156,16 +156,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.steamlog",
+      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",
@@ -396,11 +446,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);
   }
 }