Bug 1152759 - Regroup Performance Monitoring modules/components;r=yoric
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Tue, 14 Apr 2015 17:10:04 +0200
changeset 270952 023961de7f2f1d8e00f1680249b3094636524db9
parent 270951 1598f56887d75008f8569b6a07f56d4e4ffbf79a
child 270953 75502e23312183e2967738198d6b3649644d036a
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric
bugs1152759
milestone40.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 1152759 - Regroup Performance Monitoring modules/components;r=yoric
toolkit/components/aboutperformance/moz.build
toolkit/components/aboutperformance/nsIPerformanceStats.idl
toolkit/components/aboutperformance/nsPerformanceStats.cpp
toolkit/components/aboutperformance/nsPerformanceStats.h
toolkit/components/aboutperformance/tests/browser/browser.ini
toolkit/components/aboutperformance/tests/browser/browser_compartments.js
toolkit/components/aboutperformance/tests/xpcshell/test_compartments.js
toolkit/components/aboutperformance/tests/xpcshell/xpcshell.ini
toolkit/components/build/moz.build
toolkit/components/moz.build
toolkit/components/perfmonitoring/AddonWatcher.jsm
toolkit/components/perfmonitoring/PerformanceStats.jsm
toolkit/components/perfmonitoring/moz.build
toolkit/components/perfmonitoring/nsIPerformanceStats.idl
toolkit/components/perfmonitoring/nsPerformanceStats.cpp
toolkit/components/perfmonitoring/nsPerformanceStats.h
toolkit/components/perfmonitoring/tests/browser/browser.ini
toolkit/components/perfmonitoring/tests/browser/browser_AddonWatcher.js
toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample.xpi
toolkit/components/perfmonitoring/tests/browser/browser_compartments.html
toolkit/components/perfmonitoring/tests/browser/browser_compartments.js
toolkit/components/perfmonitoring/tests/browser/head.js
toolkit/components/perfmonitoring/tests/xpcshell/test_compartments.js
toolkit/components/perfmonitoring/tests/xpcshell/xpcshell.ini
toolkit/modules/AddonWatcher.jsm
toolkit/modules/PerformanceStats.jsm
toolkit/modules/moz.build
toolkit/modules/tests/browser/browser.ini
toolkit/modules/tests/browser/browser_AddonWatcher.js
toolkit/modules/tests/browser/browser_Addons_sample.xpi
--- a/toolkit/components/aboutperformance/moz.build
+++ b/toolkit/components/aboutperformance/moz.build
@@ -1,28 +1,9 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-FAIL_ON_WARNINGS = True
-
 JAR_MANIFESTS += ['jar.mn']
 
-XPIDL_MODULE = 'toolkit_perfmonitoring'
-
-XPIDL_SOURCES += [
-    'nsIPerformanceStats.idl',
-]
-
-UNIFIED_SOURCES += [
-    'nsPerformanceStats.cpp'
-]
-
-EXPORTS += [
-    'nsPerformanceStats.h'
-]
-
 BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
-XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
-
-FINAL_LIBRARY = 'xul'
--- a/toolkit/components/aboutperformance/tests/browser/browser.ini
+++ b/toolkit/components/aboutperformance/tests/browser/browser.ini
@@ -1,12 +1,11 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 [DEFAULT]
 head = head.js
-support-files =
+support-files = 
   browser_compartments.html
 
 [browser_aboutperformance.js]
 skip-if = e10s # Feature not implemented yet – bug 1140310
-[browser_compartments.js]
--- a/toolkit/components/build/moz.build
+++ b/toolkit/components/build/moz.build
@@ -11,22 +11,22 @@ EXPORTS += [
 SOURCES += [
     'nsToolkitCompsModule.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../../xre',
-    '../aboutperformance',
     '../alerts',
     '../downloads',
     '../feeds',
     '../find',
     '../jsdownloads/src',
+    '../perfmonitoring',
     '../protobuf',
     '../startup',
     '../statusfilter',
     '../typeaheadfind',
     '../url-classifier',
 ]
 
 if not CONFIG['MOZ_DISABLE_PARENTAL_CONTROLS']:
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -31,16 +31,17 @@ DIRS += [
     'find',
     'jsdownloads',
     'mediasniffer',
     'microformats',
     'osfile',
     'parentalcontrols',
     'passwordmgr',
     'perf',
+    'perfmonitoring',
     'places',
     'processsingleton',
     'promiseworker',
     'prompts',
     'protobuf',
     'reader',
     'reflect',
     'sqlite',
rename from toolkit/modules/AddonWatcher.jsm
rename to toolkit/components/perfmonitoring/AddonWatcher.jsm
rename from toolkit/modules/PerformanceStats.jsm
rename to toolkit/components/perfmonitoring/PerformanceStats.jsm
new file mode 100644
--- /dev/null
+++ b/toolkit/components/perfmonitoring/moz.build
@@ -0,0 +1,31 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
+BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
+
+FAIL_ON_WARNINGS = True
+
+XPIDL_MODULE = 'toolkit_perfmonitoring'
+
+EXTRA_JS_MODULES += [
+    'AddonWatcher.jsm',
+    'PerformanceStats.jsm',
+]
+
+XPIDL_SOURCES += [
+    'nsIPerformanceStats.idl',
+]
+
+UNIFIED_SOURCES += [
+    'nsPerformanceStats.cpp'
+]
+
+EXPORTS += [
+    'nsPerformanceStats.h'
+]
+
+FINAL_LIBRARY = 'xul'
rename from toolkit/components/aboutperformance/nsIPerformanceStats.idl
rename to toolkit/components/perfmonitoring/nsIPerformanceStats.idl
rename from toolkit/components/aboutperformance/nsPerformanceStats.cpp
rename to toolkit/components/perfmonitoring/nsPerformanceStats.cpp
rename from toolkit/components/aboutperformance/nsPerformanceStats.h
rename to toolkit/components/perfmonitoring/nsPerformanceStats.h
new file mode 100644
--- /dev/null
+++ b/toolkit/components/perfmonitoring/tests/browser/browser.ini
@@ -0,0 +1,8 @@
+[DEFAULT]
+head = head.js
+support-files =
+  browser_Addons_sample.xpi
+  browser_compartments.html
+
+[browser_AddonWatcher.js]
+[browser_compartments.js]
rename from toolkit/modules/tests/browser/browser_AddonWatcher.js
rename to toolkit/components/perfmonitoring/tests/browser/browser_AddonWatcher.js
--- a/toolkit/modules/tests/browser/browser_AddonWatcher.js
+++ b/toolkit/components/perfmonitoring/tests/browser/browser_AddonWatcher.js
@@ -1,23 +1,21 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests for AddonWatcher.jsm
 
 "use strict";
 
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
 Cu.import("resource://gre/modules/Promise.jsm", this);
 Cu.import("resource://gre/modules/AddonManager.jsm", this);
 Cu.import("resource://gre/modules/AddonWatcher.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 
-const ADDON_URL = "http://example.com/browser/toolkit/modules/tests/browser/browser_Addons_sample.xpi";
+const ADDON_URL = "http://example.com/browser/toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample.xpi";
 const ADDON_ID = "addonwatcher-test@mozilla.com";
 
 add_task(function* init() {
   AddonWatcher.uninit();
 
   info("Installing test add-on");
   let installer = yield new Promise(resolve => AddonManager.getInstallForURL(ADDON_URL, resolve, "application/x-xpinstall"));
   if (installer.error) {
rename from toolkit/modules/tests/browser/browser_Addons_sample.xpi
rename to toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample.xpi
copy from toolkit/components/aboutperformance/tests/browser/browser_compartments.html
copy to toolkit/components/perfmonitoring/tests/browser/browser_compartments.html
rename from toolkit/components/aboutperformance/tests/browser/browser_compartments.js
rename to toolkit/components/perfmonitoring/tests/browser/browser_compartments.js
--- a/toolkit/components/aboutperformance/tests/browser/browser_compartments.js
+++ b/toolkit/components/perfmonitoring/tests/browser/browser_compartments.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 Cu.import("resource://gre/modules/PerformanceStats.jsm", this);
 Cu.import("resource://testing-common/ContentTask.jsm", this);
 
-const URL = "http://example.com/browser/toolkit/components/aboutperformance/tests/browser/browser_compartments.html?test=" + Math.random();
+const URL = "http://example.com/browser/toolkit/components/perfmonitoring/tests/browser/browser_compartments.html?test=" + Math.random();
 
 // This function is injected as source as a frameScript
 function frameScript() {
   "use strict";
 
   const { utils: Cu, classes: Cc, interfaces: Ci } = Components;
   Cu.import("resource://gre/modules/PerformanceStats.jsm");
 
@@ -44,38 +44,38 @@ function monotinicity_tester(source, tes
   // - there is at most one component with a combination of `name` and `addonId`;
   // - types, etc.
   let previous = {
     processData: null,
     componentsMap: new Map(),
   };
 
   let sanityCheck = function(prev, next) {
-    dump(`Sanity check: ${JSON.stringify(next, null, "\t")}\n`);
+    info(`Sanity check: ${JSON.stringify(next, null, "\t")}`);
     if (prev == null) {
       return;
     }
     for (let k of ["name", "addonId", "isSystem"]) {
-      Assert.equal(prev[k], next[k], `Sanity check (${name}): ${k} hasn't changed.`);
+      Assert.equal(prev[k], next[k], `Sanity check (${testName}): ${k} hasn't changed.`);
     }
     for (let k of ["totalUserTime", "totalSystemTime", "totalCPOWTime", "ticks"]) {
-      Assert.equal(typeof next[k], "number", `Sanity check (${name}): ${k} is a number.`);
-      Assert_leq(prev[k], next[k], `Sanity check (${name}): ${k} is monotonic.`);
-      Assert_leq(0, next[k], `Sanity check (${name}): ${k} is >= 0.`)
+      Assert.equal(typeof next[k], "number", `Sanity check (${testName}): ${k} is a number.`);
+      Assert_leq(prev[k], next[k], `Sanity check (${testName}): ${k} is monotonic.`);
+      Assert_leq(0, next[k], `Sanity check (${testName}): ${k} is >= 0.`)
     }
     Assert.equal(prev.durations.length, next.durations.length);
     for (let i = 0; i < next.durations.length; ++i) {
       Assert.ok(typeof next.durations[i] == "number" && next.durations[i] >= 0,
-        `Sanity check (${name}): durations[${i}] is a non-negative number.`);
+        `Sanity check (${testName}): durations[${i}] is a non-negative number.`);
       Assert_leq(prev.durations[i], next.durations[i],
-        `Sanity check (${name}): durations[${i}] is monotonic.`)
+        `Sanity check (${testName}): durations[${i}] is monotonic.`)
     }
     for (let i = 0; i < next.durations.length - 1; ++i) {
       Assert_leq(next.durations[i + 1], next.durations[i],
-        `Sanity check (${name}): durations[${i}] >= durations[${i + 1}].`)
+        `Sanity check (${testName}): durations[${i}] >= durations[${i + 1}].`)
     }
   };
   let iteration = 0;
   let frameCheck = Task.async(function*() {
     let name = `${testName}: ${iteration++}`;
     let snapshot = yield source();
     if (!snapshot) {
       // This can happen at the end of the test when we attempt
@@ -98,17 +98,17 @@ function monotinicity_tester(source, tes
       let key = `{name: ${item.name}, addonId: ${item.addonId}, isSystem: ${item.isSystem}}`;
       keys.push(key);
       set.add(key);
       sanityCheck(previous.componentsMap.get(key), item);
       previous.componentsMap.set(key, item);
 
       for (let k of ["totalUserTime", "totalSystemTime", "totalCPOWTime"]) {
         Assert_leq(item[k], snapshot.processData[k],
-          `Sanity check (${name}): component has a lower ${k} than process`);
+          `Sanity check (${testName}): component has a lower ${k} than process`);
       }
     }
     // Check that we do not have duplicate components.
     info(`Before deduplication, we had the following components: ${keys.sort().join(", ")}`);
     info(`After deduplication, we have the following components: ${[...set.keys()].sort().join(", ")}`);
 
     info(`Deactivating deduplication check (Bug 1150045)`);
     if (false) {
new file mode 100644
--- /dev/null
+++ b/toolkit/components/perfmonitoring/tests/browser/head.js
@@ -0,0 +1,50 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const { utils: Cu, interfaces: Ci, classes: Cc } = Components;
+
+function promiseContentResponse(browser, name, message) {
+  let mm = browser.messageManager;
+  let promise = new Promise(resolve => {
+    function removeListener() {
+      mm.removeMessageListener(name, listener);
+    }
+
+    function listener(msg) {
+      removeListener();
+      resolve(msg.data);
+    }
+
+    mm.addMessageListener(name, listener);
+    registerCleanupFunction(removeListener);
+  });
+  mm.sendAsyncMessage(name, message);
+  return promise;
+}
+function promiseContentResponseOrNull(browser, name, message) {
+  if (!browser.messageManager) {
+    return null;
+  }
+  return promiseContentResponse(browser, name, message);
+}
+
+/**
+ * `true` if we are running an OS in which the OS performance
+ * clock has a low precision and might unpredictably
+ * never be updated during the execution of the test.
+ */
+function hasLowPrecision() {
+  let [sysName, sysVersion] = [Services.sysinfo.getPropertyAsAString("name"), Services.sysinfo.getPropertyAsDouble("version")];
+  info(`Running ${sysName} version ${sysVersion}`);
+
+  if (sysName == "Windows_NT" && sysVersion < 6) {
+    info("Running old Windows, need to deactivate tests due to bad precision.");
+    return true;
+  }
+  if (sysName == "Linux" && sysVersion <= 2.6) {
+    info("Running old Linux, need to deactivate tests due to bad precision.");
+    return true;
+  }
+  info("This platform has good precision.")
+  return false;
+}
rename from toolkit/components/aboutperformance/tests/xpcshell/test_compartments.js
rename to toolkit/components/perfmonitoring/tests/xpcshell/test_compartments.js
rename from toolkit/components/aboutperformance/tests/xpcshell/xpcshell.ini
rename to toolkit/components/perfmonitoring/tests/xpcshell/xpcshell.ini
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -7,17 +7,16 @@
 XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
 BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
 MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini']
 
 SPHINX_TREES['toolkit_modules'] = 'docs'
 
 EXTRA_JS_MODULES += [
-    'AddonWatcher.jsm',
     'Battery.jsm',
     'BinarySearch.jsm',
     'BrowserUtils.jsm',
     'CertUtils.jsm',
     'CharsetMenu.jsm',
     'ClientID.jsm',
     'debug.js',
     'DeferredTask.jsm',
@@ -31,17 +30,16 @@ EXTRA_JS_MODULES += [
     'InlineSpellChecker.jsm',
     'InlineSpellCheckerContent.jsm',
     'LoadContextInfo.jsm',
     'Log.jsm',
     'NewTabUtils.jsm',
     'ObjectUtils.jsm',
     'PageMenu.jsm',
     'PageMetadata.jsm',
-    'PerformanceStats.jsm',
     'PermissionsUtils.jsm',
     'PopupNotifications.jsm',
     'Preferences.jsm',
     'PrivateBrowsingUtils.jsm',
     'ProfileAge.jsm',
     'Promise-backend.js',
     'Promise.jsm',
     'PromiseUtils.jsm',
--- a/toolkit/modules/tests/browser/browser.ini
+++ b/toolkit/modules/tests/browser/browser.ini
@@ -1,16 +1,14 @@
 [DEFAULT]
 support-files =
   dummy_page.html
   metadata_*.html
   testremotepagemanager.html
-  browser_Addons_sample.xpi
 
-[browser_AddonWatcher.js]
 [browser_Battery.js]
 [browser_Deprecated.js]
 [browser_Finder.js]
 skip-if = e10s # Bug ?????? - test already uses content scripts, but still fails only under e10s.
 [browser_Geometry.js]
 [browser_InlineSpellChecker.js]
 [browser_PageMetadata.js]
 [browser_RemotePageManager.js]