summaryrefslogtreecommitdiffstats
path: root/tools/profiler/tests/browser/browser_test_markers_gc_cc.js
blob: a4a94d60cc59f594c0678f06b817ae4ae6d97a25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* 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/. */

add_task(async function test_markers_gc_cc() {
  info("Test GC&CC markers.");

  info("Create a throwaway profile.");
  await startProfiler({});
  let tempProfileContainer = { profile: null };
  tempProfileContainer.profile = await waitSamplingAndStopAndGetProfile();

  info("Restart the profiler.");
  await startProfiler({});

  info("Throw away the previous profile, which should be garbage-collected.");
  Assert.equal(
    typeof tempProfileContainer.profile,
    "object",
    "Previously-captured profile should be an object"
  );
  delete tempProfileContainer.profile;
  Assert.equal(
    typeof tempProfileContainer.profile,
    "undefined",
    "Deleted profile should now be undefined"
  );

  info("Force GC&CC");
  SpecialPowers.gc();
  SpecialPowers.forceShrinkingGC();
  SpecialPowers.forceCC();
  SpecialPowers.gc();
  SpecialPowers.forceShrinkingGC();
  SpecialPowers.forceCC();

  info("Stop the profiler and get the profile.");
  const profile = await waitSamplingAndStopAndGetProfile();

  const markers = getInflatedMarkerData(profile.threads[0]);
  Assert.ok(
    markers.some(({ data }) => data?.type === "GCSlice"),
    "A GCSlice marker was recorded"
  );
  Assert.ok(
    markers.some(({ data }) => data?.type === "CCSlice"),
    "A CCSlice marker was recorded"
  );
});