3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"profiler-test.js"></script>
9 // Profile for 1070ms, 2140 samples.
10 var profileAndExpectations
= {
12 "functionName": "(root)",
16 "expectedTotalTime": 1070,
17 "expectedSelfTime": 4,
19 "callUID": 4174152086,
27 "expectedTotalTime": 1010,
28 "expectedSelfTime": 3.5,
29 "callUID": 1820492223,
32 "functionName": "Aaa",
37 "expectedTotalTime": 1000,
38 "expectedSelfTime": 1000,
39 "callUID": 2901333737,
43 "functionName": "Bbb",
48 "expectedTotalTime": 6.5,
49 "expectedSelfTime": 6.5,
50 "callUID": 2901333737,
61 "expectedTotalTime": 56,
62 "expectedSelfTime": 2.5,
63 "callUID": 1820492223,
66 "functionName": "Ccc",
71 "expectedTotalTime": 50,
72 "expectedSelfTime": 50,
73 "callUID": 2901333737,
77 "functionName": "Ddd",
82 "expectedTotalTime": 3.5,
83 "expectedSelfTime": 3.5,
84 "callUID": 2901333737,
91 "idleTime": 202.88199791684747,
92 "startTime": 1375445600.000847,
93 "endTime": 1375445601.070847,
96 WebInspector
.CPUProfileDataModel
.prototype._calculateTimes(profileAndExpectations
);
97 function checkExpectations(node
)
99 if (Math
.abs(node
.selfTime
- node
.expectedSelfTime
) > 0.0001) {
100 InspectorTest
.addResult("totalTime: " + node
.totalTime
+ ", expected:" + node
.expectedTotalTime
);
103 if (Math
.abs(node
.totalTime
- node
.expectedTotalTime
) > 0.0001) {
104 InspectorTest
.addResult("totalTime: " + node
.totalTime
+ ", expected:" + node
.expectedTotalTime
);
107 for (var i
= 0; i
< node
.children
.length
; i
++) {
108 if (!checkExpectations(node
.children
[i
]))
113 if (checkExpectations(profileAndExpectations
.head
))
114 InspectorTest
.addResult("SUCCESS: all nodes have correct self and total times");
116 InspectorTest
.addResult("FAIL: incorrect node times\n" + JSON
.stringify(profileAndExpectations
, null, 4));
117 InspectorTest
.completeTest();
122 <body onload=
"runTest()">
124 Tests self and total time calculation in CPU profiler.