gecko-dev/browser/devtools/performance/test/browser_profiler_tree-model-03.js

92 lines
2.7 KiB
JavaScript
Raw Normal View History

2014-08-06 15:25:18 +00:00
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if a call tree model can be correctly computed from a samples array,
* while at the same time filtering by duration.
*/
function test() {
Bug 1101235 - Move tree utilities out of profiler, r=vp --HG-- rename : browser/devtools/profiler/test/browser_profiler_categories.js => browser/devtools/performance/test/browser_profiler_categories.js rename : browser/devtools/profiler/test/browser_profiler_content-check.js => browser/devtools/performance/test/browser_profiler_content-check.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-01.js => browser/devtools/performance/test/browser_profiler_tree-abstract-01.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-02.js => browser/devtools/performance/test/browser_profiler_tree-abstract-02.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-03.js => browser/devtools/performance/test/browser_profiler_tree-abstract-03.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-04.js => browser/devtools/performance/test/browser_profiler_tree-abstract-04.js rename : browser/devtools/profiler/test/browser_profiler_tree-frame-node.js => browser/devtools/performance/test/browser_profiler_tree-frame-node.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-01.js => browser/devtools/performance/test/browser_profiler_tree-model-01.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-02.js => browser/devtools/performance/test/browser_profiler_tree-model-02.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-03.js => browser/devtools/performance/test/browser_profiler_tree-model-03.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-04.js => browser/devtools/performance/test/browser_profiler_tree-model-04.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-05.js => browser/devtools/performance/test/browser_profiler_tree-model-05.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-01.js => browser/devtools/performance/test/browser_profiler_tree-view-01.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-02.js => browser/devtools/performance/test/browser_profiler_tree-view-02.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-03.js => browser/devtools/performance/test/browser_profiler_tree-view-03.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-04.js => browser/devtools/performance/test/browser_profiler_tree-view-04.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-05.js => browser/devtools/performance/test/browser_profiler_tree-view-05.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-06.js => browser/devtools/performance/test/browser_profiler_tree-view-06.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-07.js => browser/devtools/performance/test/browser_profiler_tree-view-07.js rename : browser/devtools/timeline/test/browser_timeline_blueprint.js => browser/devtools/performance/test/browser_timeline_blueprint.js rename : browser/devtools/profiler/utils/global.js => browser/devtools/shared/profiler/global.js rename : browser/devtools/profiler/utils/tree-model.js => browser/devtools/shared/profiler/tree-model.js rename : browser/devtools/profiler/utils/tree-view.js => browser/devtools/shared/profiler/tree-view.js rename : browser/devtools/timeline/widgets/global.js => browser/devtools/shared/timeline/global.js rename : browser/devtools/timeline/widgets/marker-details.js => browser/devtools/shared/timeline/marker-details.js rename : browser/devtools/timeline/widgets/markers-overview.js => browser/devtools/shared/timeline/markers-overview.js rename : browser/devtools/timeline/widgets/memory-overview.js => browser/devtools/shared/timeline/memory-overview.js rename : browser/devtools/timeline/widgets/waterfall.js => browser/devtools/shared/timeline/waterfall.js
2015-02-11 20:23:32 +00:00
let { ThreadNode } = devtools.require("devtools/shared/profiler/tree-model");
2014-08-06 15:25:18 +00:00
// Create a root node from a given samples array, filtering by time.
//
// Filtering from 5 to 18 includes the 2nd and 3rd samples. The 2nd sample
// starts exactly on 5 and ends at 11. The 3rd sample starts at 11 and ends
// exactly at 18.
let startTime = 5;
let endTime = 18;
let root = getFrameNodePath(new ThreadNode(gThread, { startTime, endTime }), "(root)");
2014-08-06 15:25:18 +00:00
// Test the root node.
is(root.duration, endTime - startTime,
2014-08-06 15:25:18 +00:00
"The correct duration was calculated for the root node.");
is(root.calls.length, 1,
2014-08-06 15:25:18 +00:00
"The correct number of child calls were calculated for the root node.");
ok(getFrameNodePath(root, "A"),
2014-08-06 15:25:18 +00:00
"The root node's only child call is correct.");
// Test all the descendant nodes.
is(getFrameNodePath(root, "A").calls.length, 2,
"The correct number of child calls were calculated for the 'A' node.");
ok(getFrameNodePath(root, "A > B"),
"The 'A' node has a 'B' child call.");
ok(getFrameNodePath(root, "A > E"),
"The 'A' node has a 'E' child call.");
2014-08-06 15:25:18 +00:00
is(getFrameNodePath(root, "A > B").calls.length, 1,
"The correct number of child calls were calculated for the 'A > B' node.");
ok(getFrameNodePath(root, "A > B > D"),
"The 'A > B' node's only child call is correct.");
2014-08-06 15:25:18 +00:00
is(getFrameNodePath(root, "A > E").calls.length, 1,
"The correct number of child calls were calculated for the 'A > E' node.");
ok(getFrameNodePath(root, "A > E > F"),
"The 'A > E' node's only child call is correct.");
2014-08-06 15:25:18 +00:00
is(getFrameNodePath(root, "A > B > D").calls.length, 0,
"The correct number of child calls were calculated for the 'A > B > D' node.");
is(getFrameNodePath(root, "A > E > F").calls.length, 0,
"The correct number of child calls were calculated for the 'A > E > F' node.");
2014-08-06 15:25:18 +00:00
finish();
}
let gThread = synthesizeProfileForTest([{
2014-08-06 15:25:18 +00:00
time: 5,
frames: [
{ location: "(root)" },
{ location: "A" },
{ location: "B" },
{ location: "C" }
]
}, {
time: 5 + 6,
frames: [
{ location: "(root)" },
{ location: "A" },
{ location: "B" },
{ location: "D" }
]
}, {
time: 5 + 6 + 7,
frames: [
{ location: "(root)" },
{ location: "A" },
{ location: "E" },
{ location: "F" }
]
}, {
time: 5 + 6 + 7 + 8,
frames: [
{ location: "(root)" },
{ location: "A" },
{ location: "B" },
{ location: "C" },
{ location: "D" }
]
}]);