1function test()
2{
3    WebInspector.showPanel("profiles");
4    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_buildEdgeIndexes");
5    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_buildRetainers");
6    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_buildDominatedNodes");
7    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_calculateFlags");
8    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_buildAggregates");
9    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_calculateClassesRetainedSize");
10    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_calculateDistances");
11    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_calculateRetainedSizes");
12    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_markDetachedDOMTreeNodes");
13    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_markQueriableHeapObjects");
14    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_markPageOwnedNodes");
15    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_splitNodesAndContainmentEdges");
16    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_buildPostOrderIndex");
17    InspectorTest.measureFunction(WebInspector.JSHeapSnapshot.prototype, "_buildDominatorTree");
18    InspectorTest.measureFunction(WebInspector.HeapSnapshotConstructorsDataGrid.prototype, "_aggregatesReceived");
19
20    function performanceTest(timer)
21    {
22        var transferTimerCookie;
23        var showTimerCookie;
24        var changeViewTimerCookie;
25        var clearTimerCookie;
26
27        var testName = /([^\/]+)\.html$/.exec(WebInspector.inspectedPageURL)[1];
28        var fullTimerCookie = timer.start("full-summary-snapshot-time");
29        var type = WebInspector.panels.profiles.getProfileType("HEAP");
30
31        var backendTimerCookie = timer.start("take-snapshot");
32        type._takeHeapSnapshot(step0);
33
34        function step0()
35        {
36            timer.finish(backendTimerCookie);
37            transferTimerCookie = timer.start("transfer-snapshot");
38            var profiles = type.getProfiles();
39            InspectorTest.addSniffer(profiles[0], "_updateTransferProgress", onUpdateTransferProgress, true);
40            InspectorTest.addSniffer(profiles[0], "_wasShown", step2);
41        }
42
43        function onUpdateTransferProgress(saved, total)
44        {
45            if (saved !== total)
46                return;
47            timer.finish(transferTimerCookie);
48            showTimerCookie = timer.start("show-snapshot");
49        }
50
51        function step2()
52        {
53            timer.finish(showTimerCookie);
54            changeViewTimerCookie = timer.start("switch-to-containment-view");
55            InspectorTest.switchToView("Containment", cleanup);
56        }
57
58        function cleanup()
59        {
60            timer.finish(changeViewTimerCookie);
61            timer.finish(fullTimerCookie);
62            clearTimerCookie = timer.start("clear-snapshot");
63            HeapProfilerAgent.clearProfiles(done);
64            WebInspector.panels.profiles._reset();
65        }
66
67        function done()
68        {
69            timer.finish(clearTimerCookie);
70            timer.done(testName);
71        }
72    }
73
74    InspectorTest.runPerformanceTest(performanceTest, 60000);
75}
76