Bug 1226878 - Fix incorrect totals and percents in memory tool; r=jimb

When filtering, we were merging total counts and total bytes as we added
matching paths from the unfiltered tree into the new, filtered tree. This was
incorrect, and caused us to double, triple, ... count the totals.

--HG--
extra : rebase_source : 6df8ff346c938e728b912901e01671ba2ad0cc9d
This commit is contained in:
Nick Fitzgerald 2016-02-04 16:10:00 +01:00
parent 0d656a45b0
commit dd1c92ae4e
6 changed files with 109 additions and 12 deletions

View File

@ -465,9 +465,7 @@ function insertOrMergeNode(parentCacheValue, node) {
if (val) {
val.node.count += node.count;
val.node.totalCount += node.totalCount;
val.node.bytes += node.bytes;
val.node.totalBytes += node.totalBytes;
} else {
val = new CensusTreeNodeCacheValue();

View File

@ -76,9 +76,9 @@ function run_test() {
{
name: abc_Stack,
bytes: 50,
totalBytes: 50,
totalBytes: 10,
count: 5,
totalCount: 5,
totalCount: 1,
children: [
{
name: null,
@ -93,9 +93,9 @@ function run_test() {
{
name: abc_Stack.parent,
bytes: 0,
totalBytes: 30,
totalBytes: 10,
count: 0,
totalCount: 3,
totalCount: 1,
children: [
{
name: null,

View File

@ -53,9 +53,9 @@ function run_test() {
{
name: "objects",
bytes: 0,
totalBytes: 1350,
totalBytes: 450,
count: 0,
totalCount: 135,
totalCount: 45,
children: [
{
name: "Int32Array",

View File

@ -48,16 +48,16 @@ function run_test() {
{
name: stack1.parent.parent,
bytes: 0,
totalBytes: 180,
totalBytes: 60,
count: 0,
totalCount: 18,
totalCount: 6,
children: [
{
name: stack2.parent,
bytes: 0,
totalBytes: 100,
totalBytes: 50,
count: 0,
totalCount: 10,
totalCount: 5,
children: [
{
name: stack3,

View File

@ -0,0 +1,98 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test the filtered nodes' counts and bytes are the same as they were when
// unfiltered.
function run_test() {
const COUNT = { by: "count", count: true, bytes: true };
const INTERNAL_TYPE = { by: "internalType", then: COUNT };
const BREAKDOWN = {
by: "coarseType",
objects: { by: "objectClass", then: COUNT, other: COUNT },
strings: COUNT,
scripts: {
by: "filename",
then: INTERNAL_TYPE,
noFilename: INTERNAL_TYPE
},
other: INTERNAL_TYPE,
};
const REPORT = {
objects: {
Function: {
count: 7,
bytes: 70
},
Array: {
count: 6,
bytes: 60
}
},
scripts: {
"http://mozilla.github.io/pdf.js/build/pdf.js": {
"js::LazyScript": {
count: 4,
bytes: 40
},
}
},
strings: {
count: 2,
bytes: 20
},
other: {
"js::Shape": {
count: 1,
bytes: 10
}
}
};
const EXPECTED = {
name: null,
bytes: 0,
totalBytes: 200,
count: 0,
totalCount: 20,
parent: undefined,
children: [
{
name: "objects",
bytes: 0,
totalBytes: 130,
count: 0,
totalCount: 13,
children: [
{
name: "Function",
bytes: 70,
totalBytes: 70,
count: 7,
totalCount: 7,
id: 13,
parent: 12,
children: undefined
},
{
name: "Array",
bytes: 60,
totalBytes: 60,
count: 6,
totalCount: 6,
id: 14,
parent: 12,
children: undefined
},
],
id: 12,
parent: 11
}
],
id: 11
};
compareCensusViewData(BREAKDOWN, REPORT, EXPECTED, { filter: "objects" });
}

View File

@ -20,6 +20,7 @@ support-files =
[test_census_filtering_01.js]
[test_census_filtering_02.js]
[test_census_filtering_03.js]
[test_census_filtering_04.js]
[test_census-tree-node-01.js]
[test_census-tree-node-02.js]
[test_census-tree-node-03.js]