зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1217495 - HeapAnalyses{Client,Worker} should support requests for inverted trees; r=jsantell
This commit is contained in:
Родитель
fa0f765d51
Коммит
e2f0c08d79
|
@ -69,6 +69,9 @@ HeapAnalysesClient.prototype.readHeapSnapshot = function (snapshotFilePath) {
|
|||
* Whether or not the census is returned as a CensusTreeNode,
|
||||
* or just a breakdown report. Defaults to false.
|
||||
* @see `devtools/shared/heapsnapshot/census-tree-node.js`
|
||||
* - {Boolean} asInvertedTreeNode
|
||||
* Whether or not the census is returned as an inverted
|
||||
* CensusTreeNode. Defaults to false.
|
||||
*
|
||||
* @returns Promise<census report|CensusTreeNode>
|
||||
* The report generated by the given census breakdown, or
|
||||
|
@ -106,6 +109,9 @@ HeapAnalysesClient.prototype.takeCensus = function (snapshotFilePath,
|
|||
* - {Boolean} asTreeNode
|
||||
* Whether the resulting delta report should be converted to a census
|
||||
* tree node before returned. Defaults to false.
|
||||
* - {Boolean} asInvertedTreeNode
|
||||
* Whether or not the census is returned as an inverted
|
||||
* CensusTreeNode. Defaults to false.
|
||||
*
|
||||
* @returns Promise<delta report|CensusTreeNode>
|
||||
* The delta report generated by diffing the two census reports, or a
|
||||
|
|
|
@ -37,9 +37,14 @@ workerHelper.createTask(self, "takeCensus", ({ snapshotFilePath, censusOptions,
|
|||
}
|
||||
|
||||
let report = snapshots[snapshotFilePath].takeCensus(censusOptions);
|
||||
return requestOptions.asTreeNode
|
||||
? censusReportToCensusTreeNode(censusOptions.breakdown, report)
|
||||
: report;
|
||||
|
||||
if (requestOptions.asTreeNode) {
|
||||
return censusReportToCensusTreeNode(censusOptions.breakdown, report);
|
||||
} else if (requestOptions.asInvertedTreeNode) {
|
||||
return censusReportToCensusTreeNode(censusOptions.breakdown, report, { invert: true });
|
||||
} else {
|
||||
return report;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -65,7 +70,11 @@ workerHelper.createTask(self, "takeCensusDiff", request => {
|
|||
const second = snapshots[secondSnapshotFilePath].takeCensus(censusOptions);
|
||||
const delta = CensusUtils.diff(censusOptions.breakdown, first, second);
|
||||
|
||||
return requestOptions.asTreeNode
|
||||
? censusReportToCensusTreeNode(censusOptions.breakdown, delta)
|
||||
: delta;
|
||||
if (requestOptions.asTreeNode) {
|
||||
return censusReportToCensusTreeNode(censusOptions.breakdown, delta);
|
||||
} else if (requestOptions.asInvertedTreeNode) {
|
||||
return censusReportToCensusTreeNode(censusOptions.breakdown, delta, { invert: true });
|
||||
} else {
|
||||
return delta;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Test that the HeapAnalyses{Client,Worker} can take diffs between censuses as
|
||||
// inverted trees.
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
const BREAKDOWN = {
|
||||
by: "coarseType",
|
||||
objects: {
|
||||
by: "objectClass",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
other: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
scripts: {
|
||||
by: "internalType",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
strings: {
|
||||
by: "internalType",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
other: {
|
||||
by: "internalType",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
};
|
||||
|
||||
add_task(function* () {
|
||||
const firstSnapshotFilePath = saveNewHeapSnapshot();
|
||||
const secondSnapshotFilePath = saveNewHeapSnapshot();
|
||||
|
||||
const client = new HeapAnalysesClient();
|
||||
yield client.readHeapSnapshot(firstSnapshotFilePath);
|
||||
yield client.readHeapSnapshot(secondSnapshotFilePath);
|
||||
|
||||
ok(true, "Should have read both heap snapshot files");
|
||||
|
||||
const delta = yield client.takeCensusDiff(firstSnapshotFilePath,
|
||||
secondSnapshotFilePath,
|
||||
{ breakdown: BREAKDOWN });
|
||||
|
||||
const deltaTreeNode = yield client.takeCensusDiff(firstSnapshotFilePath,
|
||||
secondSnapshotFilePath,
|
||||
{ breakdown: BREAKDOWN },
|
||||
{ asInvertedTreeNode: true });
|
||||
|
||||
compareCensusViewData(BREAKDOWN, delta, deltaTreeNode, { invert: true });
|
||||
|
||||
client.destroy();
|
||||
});
|
|
@ -0,0 +1,52 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Test that the HeapAnalyses{Client,Worker} can take censuses and return
|
||||
// an inverted CensusTreeNode.
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
const BREAKDOWN = {
|
||||
by: "coarseType",
|
||||
objects: {
|
||||
by: "objectClass",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
other: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
scripts: {
|
||||
by: "internalType",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
strings: {
|
||||
by: "internalType",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
other: {
|
||||
by: "internalType",
|
||||
then: { by: "count", count: true, bytes: true },
|
||||
},
|
||||
};
|
||||
|
||||
add_task(function* () {
|
||||
const client = new HeapAnalysesClient();
|
||||
|
||||
const snapshotFilePath = saveNewHeapSnapshot();
|
||||
yield client.readHeapSnapshot(snapshotFilePath);
|
||||
ok(true, "Should have read the heap snapshot");
|
||||
|
||||
const report = yield client.takeCensus(snapshotFilePath, {
|
||||
breakdown: BREAKDOWN
|
||||
});
|
||||
|
||||
const treeNode = yield client.takeCensus(snapshotFilePath, {
|
||||
breakdown: BREAKDOWN
|
||||
}, {
|
||||
asInvertedTreeNode: true
|
||||
});
|
||||
|
||||
compareCensusViewData(BREAKDOWN, report, treeNode, { invert: true });
|
||||
|
||||
client.destroy();
|
||||
});
|
|
@ -25,12 +25,14 @@ support-files =
|
|||
[test_census-tree-node-07.js]
|
||||
[test_HeapAnalyses_readHeapSnapshot_01.js]
|
||||
[test_HeapAnalyses_takeCensusDiff_01.js]
|
||||
[test_HeapAnalyses_takeCensusDiff_02.js]
|
||||
[test_HeapAnalyses_takeCensus_01.js]
|
||||
[test_HeapAnalyses_takeCensus_02.js]
|
||||
[test_HeapAnalyses_takeCensus_03.js]
|
||||
[test_HeapAnalyses_takeCensus_04.js]
|
||||
[test_HeapAnalyses_takeCensus_05.js]
|
||||
[test_HeapAnalyses_takeCensus_06.js]
|
||||
[test_HeapAnalyses_takeCensus_07.js]
|
||||
[test_HeapSnapshot_creationTime_01.js]
|
||||
[test_HeapSnapshot_takeCensus_01.js]
|
||||
[test_HeapSnapshot_takeCensus_02.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче