tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_HeapAnalyses_takeCensusDiff_02.js (1800B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Test that the HeapAnalyses{Client,Worker} can take diffs between censuses as
      6 // inverted trees.
      7 
      8 const BREAKDOWN = {
      9  by: "coarseType",
     10  objects: {
     11    by: "objectClass",
     12    then: { by: "count", count: true, bytes: true },
     13    other: { by: "count", count: true, bytes: true },
     14  },
     15  scripts: {
     16    by: "internalType",
     17    then: { by: "count", count: true, bytes: true },
     18  },
     19  strings: {
     20    by: "internalType",
     21    then: { by: "count", count: true, bytes: true },
     22  },
     23  other: {
     24    by: "internalType",
     25    then: { by: "count", count: true, bytes: true },
     26  },
     27  domNode: {
     28    by: "descriptiveType",
     29    then: { by: "count", count: true, bytes: true },
     30  },
     31 };
     32 
     33 add_task(async function () {
     34  const firstSnapshotFilePath = saveNewHeapSnapshot();
     35  const secondSnapshotFilePath = saveNewHeapSnapshot();
     36 
     37  const client = new HeapAnalysesClient();
     38  await client.readHeapSnapshot(firstSnapshotFilePath);
     39  await client.readHeapSnapshot(secondSnapshotFilePath);
     40 
     41  ok(true, "Should have read both heap snapshot files");
     42 
     43  const { delta } = await client.takeCensusDiff(
     44    firstSnapshotFilePath,
     45    secondSnapshotFilePath,
     46    { breakdown: BREAKDOWN }
     47  );
     48 
     49  const { delta: deltaTreeNode } = await client.takeCensusDiff(
     50    firstSnapshotFilePath,
     51    secondSnapshotFilePath,
     52    { breakdown: BREAKDOWN },
     53    { asInvertedTreeNode: true }
     54  );
     55 
     56  // Have to manually set these because symbol properties aren't structured
     57  // cloned.
     58  delta[CensusUtils.basisTotalBytes] = deltaTreeNode.totalBytes;
     59  delta[CensusUtils.basisTotalCount] = deltaTreeNode.totalCount;
     60 
     61  compareCensusViewData(BREAKDOWN, delta, deltaTreeNode, { invert: true });
     62 
     63  client.destroy();
     64 });