Bug 1572337: Test that we get non-0 responsiveness values in the profiler r=gregtatum
☠☠ backed out by 3334e244dd72 ☠ ☠
authorRandell Jesup <rjesup@wgate.com>
Thu, 07 Nov 2019 12:53:37 +0000
changeset 501074 fc8a37c2c22cc09e618b185dc3803eec453334b6
parent 501073 144a647fff17bf1f69c6d1589daa185514327258
child 501075 25f074eb507493b25d145c16787022d5f9926bde
push id114167
push usercsabou@mozilla.com
push dateFri, 08 Nov 2019 00:35:25 +0000
treeherdermozilla-inbound@ac63c8962183 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgregtatum
bugs1572337
milestone72.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 1572337: Test that we get non-0 responsiveness values in the profiler r=gregtatum Differential Revision: https://phabricator.services.mozilla.com/D41637
toolkit/components/extensions/test/xpcshell/test_ext_geckoProfiler_schema.js
tools/profiler/tests/xpcshell/test_responsiveness.js
tools/profiler/tests/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/test/xpcshell/test_ext_geckoProfiler_schema.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_geckoProfiler_schema.js
@@ -42,13 +42,15 @@ add_task(async function() {
   for (const feature of allFeaturesAcceptedByProfiler) {
     ok(
       acceptedFeatures.includes(feature),
       `The schema of the geckoProfiler.start() method should accept the "${feature}" feature.`
     );
   }
   for (const feature of acceptedFeatures) {
     ok(
-      allFeaturesAcceptedByProfiler.includes(feature),
+      // Bug 1594566 - ignore Responsiveness until the extension is updated
+      allFeaturesAcceptedByProfiler.includes(feature) ||
+        feature == "responsiveness",
       `The schema of the geckoProfiler.start() method mentions a "${feature}" feature which is not supported by the profiler.`
     );
   }
 });
new file mode 100644
--- /dev/null
+++ b/tools/profiler/tests/xpcshell/test_responsiveness.js
@@ -0,0 +1,53 @@
+/* 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/. */
+
+/**
+ * Test that we can measure non-zero event delays (responsiveness)
+ */
+
+add_task(async () => {
+  if (!AppConstants.MOZ_GECKO_PROFILER) {
+    return;
+  }
+  const entries = 10000;
+  const interval = 1;
+  const threads = [];
+  const features = [];
+
+  Services.profiler.StartProfiler(entries, interval, features, threads);
+
+  await functionA();
+
+  const profile = await Services.profiler.getProfileDataAsync();
+  const [thread] = profile.threads;
+  const { samples } = thread;
+  const message = "Responsiveness > 0 not found.";
+  let SAMPLE_STACK_SLOT = thread.samples.schema.responsiveness;
+
+  for (let i = 0; i < samples.data.length; i++) {
+    if (samples.data[i][SAMPLE_STACK_SLOT] > 0) {
+      Assert.ok(true, message);
+      return;
+    }
+  }
+  Assert.ok(false, message);
+});
+
+function doSyncWork(milliseconds) {
+  const start = Date.now();
+  while (true) {
+    this.n = 0;
+    for (let i = 0; i < 1e5; i++) {
+      this.n += Math.random();
+    }
+    if (Date.now() - start > milliseconds) {
+      return;
+    }
+  }
+}
+
+function functionA() {
+  doSyncWork(100);
+  doAtLeastOnePeriodicSample();
+}
--- a/tools/profiler/tests/xpcshell/xpcshell.ini
+++ b/tools/profiler/tests/xpcshell/xpcshell.ini
@@ -1,16 +1,17 @@
 [DEFAULT]
 head = head_profiler.js
 skip-if = toolkit == 'android'
 
 [test_active_configuration.js]
 [test_start.js]
 skip-if = true
 [test_get_features.js]
+[test_responsiveness.js]
 [test_shared_library.js]
 [test_run.js]
 skip-if = true
 [test_pause.js]
 [test_enterjit_osr.js]
 skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536652
 [test_enterjit_osr_disabling.js]
 skip-if = !debug