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