Bug 1239750 - Add DAMP measurement for bulk console.log performance;r=fitzgen
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 20 Jan 2016 20:43:27 -0800
changeset 280937 24afa30a759c
parent 280936 57cd47c177f6
child 280938 63e4b33812a9
push id29924
push userkwierso@gmail.com
push dateThu, 21 Jan 2016 22:17:57 +0000
treeherdermozilla-central@f36a4a4ff73f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1239750
milestone46.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 1239750 - Add DAMP measurement for bulk console.log performance;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
@@ -12,27 +12,29 @@ var defaultConfig = {
   subtests: {
     webconsoleOpen: true,
     inspectorOpen: true,
     debuggerOpen: true,
     styleEditorOpen: true,
     performanceOpen: true,
     netmonitorOpen: true,
     saveAndReadHeapSnapshot: true,
+    consoleBulkLogging: 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",
 };
 
 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
@@ -107,16 +107,65 @@ Damp.prototype = {
     let end = performance.now();
     this._results.push({
       name: label + ".readHeapSnapshot",
       value: end - start
     });
     return Promise.resolve();
   },
 
+  _consoleBulkLoggingTest: Task.async(function*() {
+    let TOTAL_MESSAGES = 10;
+    let tab = yield this.testSetup(SIMPLE_URL);
+    let messageManager = tab.linkedBrowser.messageManager;
+    let {toolbox} = yield this.openToolbox("webconsole");
+    let webconsole = toolbox.getPanel("webconsole");
+
+    // Resolve once the last message has been received.
+    let allMessagesReceived = new Promise(resolve => {
+      function receiveMessages(e, messages) {
+        for (let m of messages) {
+          if (m.node.textContent.includes("damp " + TOTAL_MESSAGES)) {
+            webconsole.hud.ui.off("new-messages", receiveMessages);
+            // Wait for the console to redraw
+            requestAnimationFrame(resolve);
+          }
+        }
+      }
+      webconsole.hud.ui.on("new-messages", receiveMessages);
+    });
+
+    // 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 () {
+        addMessageListener("do-logs", function () {
+          for (var i = 0; i < ${TOTAL_MESSAGES}; i++) {
+            content.console.log('damp', i+1, content);
+          }
+        });
+      }`
+    ) + ")()", true);
+
+    // Kick off the logging
+    messageManager.sendAsyncMessage("do-logs");
+
+    let start = performance.now();
+    yield allMessagesReceived;
+    let end = performance.now();
+
+    this._results.push({
+      name: "console.bulklog",
+      value: end - start
+    });
+
+    yield this.closeToolbox(null);
+    yield this.testTeardown();
+  }),
+
   takeCensus: function(label) {
     let start = performance.now();
 
     this._snapshot.takeCensus({
       breakdown: {
         by: "coarseType",
         objects: {
           by: "objectClass",
@@ -239,20 +288,21 @@ Damp.prototype = {
         sequenceArray.push(subtests[config.subtests[i]]);
       }
     }
 
     return sequenceArray;
   },
 
   testSetup: Task.async(function*(url) {
-    yield this.addTab(url);
+    let tab = yield this.addTab(url);
     yield new Promise(resolve => {
       setTimeout(resolve, this._config.rest);
     });
+    return tab;
   }),
 
   testTeardown: Task.async(function*(url) {
     this.closeCurrentTab();
     this._nextCommand();
   }),
 
   // Everything below here are common pieces needed for the test runner to function,
@@ -342,11 +392,15 @@ Damp.prototype = {
     this._dampTab = this._win.gBrowser.selectedTab;
     this._win.gBrowser.selectedBrowser.focus(); // Unfocus the URL bar to avoid caret blink
 
     Profiler.mark("DAMP - start", true);
 
     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);
+    }
     this._doSequence(tests, this._doneInternal);
   }
 }