516dbb4572d0672acb2f19d26f8b8479134b1f1a
[WebKit-https.git] / PerformanceTests / inspector / heap-snapshot-performance-test.js
1 function test()
2 {
3     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildEdgeIndexes");
4     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildRetainers");
5     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildDominatedNodes");
6     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateFlags");
7     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildAggregates");
8     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateClassesRetainedSize");
9     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateObjectToWindowDistance");
10     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateRetainedSizes");
11     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_markDetachedDOMTreeNodes");
12     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_markQueriableHeapObjects");
13     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_markPageOwnedNodes");
14     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_splitNodesAndContainmentEdges");
15     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildPostOrderIndex");
16     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildDominatorTree");
17     InspectorTest.measureFunction(WebInspector.HeapSnapshotConstructorsDataGrid.prototype, "_aggregatesReceived");
18
19     function performanceTest(timer)
20     {
21         var transferTimerCookie;
22         var showTimerCookie;
23         var changeViewTimerCookie;
24         var clearTimerCookie;
25
26         var testName = /([^\/]+)\.html$/.exec(WebInspector.inspectedPageURL)[1];
27         var fullTimerCookie = timer.start("full-summary-snapshot-time");
28         var backendTimerCookie = timer.start("take-snapshot");
29         ProfilerAgent.takeHeapSnapshot(step0);
30
31         function step0()
32         {
33             timer.finish(backendTimerCookie);
34             transferTimerCookie = timer.start("transfer-snapshot");
35             var profiles = WebInspector.panels.profiles.getProfiles("HEAP");
36             WebInspector.panels.profiles.showProfile(profiles[profiles.length - 1]);
37             InspectorTest.addSniffer(WebInspector.panels.profiles, "_finishHeapSnapshot", step1);
38         }
39
40         function step1(uid)
41         {
42             timer.finish(transferTimerCookie);
43             showTimerCookie = timer.start("show-snapshot");
44             var panel = WebInspector.panels.profiles;
45             var profile = panel._profilesIdMap[panel._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)];
46             profile.load(step2); // Add load callback.
47         }
48
49         function step2()
50         {
51             timer.finish(showTimerCookie);
52             changeViewTimerCookie = timer.start("switch-to-containment-view");
53             InspectorTest.switchToView("Containment", cleanup);
54         }
55
56         function cleanup()
57         {
58             timer.finish(changeViewTimerCookie);
59             timer.finish(fullTimerCookie);
60             clearTimerCookie = timer.start("clear-snapshot");
61             ProfilerAgent.clearProfiles(done);
62             WebInspector.panels.profiles._reset();
63         }
64
65         function done()
66         {
67             timer.finish(clearTimerCookie);
68             timer.done(testName);
69         }
70     }
71
72     InspectorTest.runPerformanceTest(performanceTest, 60000);
73 }