Bug 1633625 - Basic shell harness for running the GC microbenchmarks r=jonco
authorSteve Fink <sfink@mozilla.com>
Tue, 19 May 2020 21:55:11 +0000
changeset 530908 462f792e609d6eee84e2a79c7cc562ca44e09c46
parent 530907 6fd685c690a80000c5736b02cbaa59716d0d0269
child 530909 6c6d07b53773ce6307ce79df7b7a4a3695296e84
push id37434
push userabutkovits@mozilla.com
push dateWed, 20 May 2020 10:05:10 +0000
treeherdermozilla-central@005ef1c25992 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1633625
milestone78.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 1633625 - Basic shell harness for running the GC microbenchmarks r=jonco Differential Revision: https://phabricator.services.mozilla.com/D75009
js/src/devtools/gc-ubench/spidermonkey.js
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/spidermonkey.js
@@ -0,0 +1,93 @@
+var FPS = 60;
+var gNumSamples = 500;
+
+var waited = 0;
+
+////////////// Host functionality /////////////////
+
+function start_turn() {}
+
+function end_turn() {
+  clearKeptObjects();
+}
+
+function suspend(duration) {
+  sleep(duration);
+}
+
+///////////////// Main /////////////////
+
+loadRelativeToScript("harness.js");
+loadRelativeToScript("perf.js");
+loadRelativeToScript("test_list.js");
+
+var tests = new Map();
+foreach_test_file(f => loadRelativeToScript(f));
+for (const [name, info] of tests.entries()) {
+  if ("enabled" in info && !info.enabled) {
+    tests.delete(name);
+  }
+}
+
+function tick(loadMgr, timestamp) {
+  start_turn();
+  const events = loadMgr.tick(timestamp);
+  end_turn();
+  return events;
+}
+
+function now() {
+  return performance.now();
+}
+
+function wait_for_next_frame(t0, t1) {
+  const elapsed = (t1 - t0) / 1000;
+  const period = 1 / FPS;
+  const used = elapsed % period;
+  const delay = period - used;
+  waited += delay;
+  suspend(delay);
+}
+
+function report_events(events, loadMgr) {
+  let ended = false;
+  if (events & loadMgr.LOAD_ENDED) {
+    print(`${loadMgr.lastActive.name} ended`);
+    ended = true;
+  }
+  if (events & loadMgr.LOAD_STARTED) {
+    print(`${loadMgr.activeLoad().name} starting`);
+  }
+  return ended;
+}
+
+function run(loads) {
+  const loadMgr = new AllocationLoadManager(tests);
+  const perf = new FrameHistory(gNumSamples);
+
+  loads = loads.length ? loads : tests.keys();
+  loadMgr.startCycle(loads);
+  perf.start();
+
+  const t0 = now();
+
+  let possible = 0;
+  let frames = 0;
+  while (loadMgr.load_running()) {
+    const timestamp = now();
+    perf.on_frame(timestamp);
+    const events = tick(loadMgr, timestamp);
+    frames++;
+    if (report_events(events, loadMgr)) {
+      possible += (loadMgr.testDurationMS / 1000) * FPS;
+      print(
+        `  observed ${frames} / ${possible} frames in ${(now() - t0) /
+          1000} seconds`
+      );
+    }
+    wait_for_next_frame(t0, now());
+  }
+}
+
+run(scriptArgs);
+print(`Waited total of ${waited} seconds`);