Bug 1500072 - Add a shared helper to record metrics in tests;r=ochameau
☠☠ backed out by a3ef08e9f99e ☠ ☠
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 13 Feb 2019 09:26:03 +0000
changeset 458865 a11b90e9e698
parent 458864 96b6da57e237
child 458866 9d792d03c36b
push id35551
push usershindli@mozilla.com
push dateWed, 13 Feb 2019 21:34:09 +0000
treeherdermozilla-central@08f794a4928e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1500072
milestone67.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 1500072 - Add a shared helper to record metrics in tests;r=ochameau Depends on D19364 Differential Revision: https://phabricator.services.mozilla.com/D19582
devtools/client/framework/test/metrics/browser_metrics_inspector.js
devtools/client/framework/test/metrics/browser_metrics_webconsole.js
devtools/client/framework/test/metrics/head.js
--- a/devtools/client/framework/test/metrics/browser_metrics_inspector.js
+++ b/devtools/client/framework/test/metrics/browser_metrics_inspector.js
@@ -16,52 +16,14 @@
 const TEST_URL = "data:text/html;charset=UTF-8,<div>Inspector modules load test</div>";
 
 add_task(async function() {
   await openNewTabAndToolbox(TEST_URL, "inspector");
 
   // The inspector does not use a dedicated browser loader.
   const loaders = [loader.provider.loader];
 
-  const allModules = getFilteredModules("", loaders);
-  const inspectorModules = getFilteredModules("devtools/client/inspector", loaders);
-
-  const allModulesCount = allModules.length;
-  const inspectorModulesCount = inspectorModules.length;
-
-  const allModulesChars = countCharsInModules(allModules);
-  const inspectorModulesChars = countCharsInModules(inspectorModules);
-
-  const PERFHERDER_DATA = {
-    framework: {
-      name: "devtools",
-    },
-    suites: [{
-      name: "inspector-metrics",
-      value: allModulesChars,
-      subtests: [
-        {
-          name: "inspector-modules",
-          value: inspectorModulesCount,
-        },
-        {
-          name: "inspector-chars",
-          value: inspectorModulesChars,
-        },
-        {
-          name: "all-modules",
-          value: allModulesCount,
-        },
-        {
-          name: "all-chars",
-          value: allModulesChars,
-        },
-      ],
-    }],
-  };
-  info("PERFHERDER_DATA: " + JSON.stringify(PERFHERDER_DATA));
-
-  // Simply check that we found valid values.
-  ok(allModulesCount > inspectorModulesCount &&
-     inspectorModulesCount > 0, "Successfully recorded module count for Inspector");
-  ok(allModulesChars > inspectorModulesChars &&
-     inspectorModulesChars > 0, "Successfully recorded char count for Inspector");
+  runMetricsTest({
+    filterString: "devtools/client/inspector",
+    loaders,
+    panelName: "inspector",
+  });
 });
--- a/devtools/client/framework/test/metrics/browser_metrics_webconsole.js
+++ b/devtools/client/framework/test/metrics/browser_metrics_webconsole.js
@@ -18,52 +18,14 @@ const TEST_URL = "data:text/html;charset
 add_task(async function() {
   const toolbox = await openNewTabAndToolbox(TEST_URL, "webconsole");
   const hud = toolbox.getCurrentPanel().hud;
 
   // Retrieve the browser loader dedicated to the WebConsole.
   const webconsoleLoader = hud.ui.browserLoader;
   const loaders = [loader.provider.loader, webconsoleLoader.loader];
 
-  const allModules = getFilteredModules("", loaders);
-  const webconsoleModules = getFilteredModules("devtools/client/webconsole", loaders);
-
-  const allModulesCount = allModules.length;
-  const webconsoleModulesCount = webconsoleModules.length;
-
-  const allModulesChars = countCharsInModules(allModules);
-  const webconsoleModulesChars = countCharsInModules(webconsoleModules);
-
-  const PERFHERDER_DATA = {
-    framework: {
-      name: "devtools",
-    },
-    suites: [{
-      name: "webconsole-metrics",
-      value: allModulesChars,
-      subtests: [
-        {
-          name: "webconsole-modules",
-          value: webconsoleModulesCount,
-        },
-        {
-          name: "webconsole-chars",
-          value: webconsoleModulesChars,
-        },
-        {
-          name: "all-modules",
-          value: allModulesCount,
-        },
-        {
-          name: "all-chars",
-          value: allModulesChars,
-        },
-      ],
-    }],
-  };
-  info("PERFHERDER_DATA: " + JSON.stringify(PERFHERDER_DATA));
-
-  // Simply check that we found valid values.
-  ok(allModulesCount > webconsoleModulesCount &&
-     webconsoleModulesCount > 0, "Successfully recorded module count for WebConsole");
-  ok(allModulesChars > webconsoleModulesChars &&
-     webconsoleModulesChars > 0, "Successfully recorded char count for WebConsole");
+  runMetricsTest({
+    filterString: "devtools/client/webconsole",
+    loaders,
+    panelName: "webconsole",
+  });
 });
--- a/devtools/client/framework/test/metrics/head.js
+++ b/devtools/client/framework/test/metrics/head.js
@@ -25,8 +25,62 @@ function countCharsInModules(modules) {
     try {
       return sum + require("raw!" + uri).length;
     } catch (e) {
       // Ignore failures
       return sum;
     }
   }, 0);
 }
+
+/**
+ * Record module loading data.
+ *
+ * @param {Object}
+ * - filterString {String} path to use to filter modules specific to the current panel
+ * - loaders {Array} Array of Loaders to check for modules
+ * - panelName {String} reused in identifiers for perfherder data
+ */
+function runMetricsTest({ filterString, loaders, panelName }) {
+  const allModules = getFilteredModules("", loaders);
+  const panelModules = getFilteredModules(filterString, loaders);
+
+  const allModulesCount = allModules.length;
+  const panelModulesCount = panelModules.length;
+
+  const allModulesChars = countCharsInModules(allModules);
+  const panelModulesChars = countCharsInModules(panelModules);
+
+  const PERFHERDER_DATA = {
+    framework: {
+      name: "devtools",
+    },
+    suites: [{
+      name: panelName + "-metrics",
+      value: allModulesChars,
+      subtests: [
+        {
+          name: panelName + "-modules",
+          value: panelModulesCount,
+        },
+        {
+          name: panelName + "-chars",
+          value: panelModulesChars,
+        },
+        {
+          name: "all-modules",
+          value: allModulesCount,
+        },
+        {
+          name: "all-chars",
+          value: allModulesChars,
+        },
+      ],
+    }],
+  };
+  info("PERFHERDER_DATA: " + JSON.stringify(PERFHERDER_DATA));
+
+  // Simply check that we found valid values.
+  ok(allModulesCount > panelModulesCount &&
+     panelModulesCount > 0, "Successfully recorded module count for " + panelName);
+  ok(allModulesChars > panelModulesChars &&
+     panelModulesChars > 0, "Successfully recorded char count for " + panelName);
+}