| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="profiler-test.js"></script> | 4 <script src="profiler-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function test() | 7 function test() |
| 8 { | 8 { |
| 9 var profileAndExpectations = { | 9 var profileAndExpectations = { |
| 10 "title": "profile1", | 10 "title": "profile1", |
| 11 "target": function() { | 11 "target": function() { |
| 12 return WebInspector.targetManager.targets()[0]; | 12 return WebInspector.targetManager.targets()[0]; |
| 13 }, | 13 }, |
| 14 "_profile": { | 14 "_profile": { |
| 15 "head": { | 15 "nodes": [ |
| 16 "callFrame": | |
| 17 { | 16 { |
| 18 "functionName": "(root)", | 17 "id": 0, |
| 19 "scriptId": "0", | 18 "callFrame": |
| 20 "url": "a.js", | 19 { |
| 21 "lineNumber": 0 | 20 "functionName": "(root)", |
| 21 "scriptId": "0", |
| 22 "url": "a.js", |
| 23 "lineNumber": 0 |
| 24 }, |
| 25 "hitCount": 350, |
| 26 "children": [1, 2, 5] |
| 22 }, | 27 }, |
| 23 "hitCount": 350, | |
| 24 "callUID": 1000, | |
| 25 "children": [ | |
| 26 { | 28 { |
| 29 "id": 1, |
| 27 "callFrame": | 30 "callFrame": |
| 28 { | 31 { |
| 29 "functionName": "(idle)", | 32 "functionName": "(idle)", |
| 30 "scriptId": "0", | 33 "scriptId": "0", |
| 31 "url": "a.js", | 34 "url": "a.js", |
| 32 "lineNumber": 1 | 35 "lineNumber": 1 |
| 33 }, | 36 }, |
| 34 "hitCount": 1000, | 37 "hitCount": 1000, |
| 35 "callUID": 2, | |
| 36 "children": [] | 38 "children": [] |
| 37 }, | 39 }, |
| 38 { | 40 { |
| 41 "id": 2, |
| 39 "callFrame": | 42 "callFrame": |
| 40 { | 43 { |
| 41 "functionName": "A", | 44 "functionName": "A", |
| 42 "scriptId": "0", | 45 "scriptId": "0", |
| 43 "url": "a.js", | 46 "url": "a.js", |
| 44 "lineNumber": 4642 | 47 "lineNumber": 4642 |
| 45 }, | 48 }, |
| 46 "hitCount": 250, | 49 "hitCount": 250, |
| 47 "callUID": 1001, | 50 "children": [3] |
| 48 "children": [ | |
| 49 { | |
| 50 "callFrame": | |
| 51 { | |
| 52 "functionName": "C", | |
| 53 "scriptId": "0", | |
| 54 "url": "a.js", | |
| 55 "lineNumber": 525 | |
| 56 }, | |
| 57 "hitCount": 100, | |
| 58 "callUID": 2000, | |
| 59 "children": [ | |
| 60 { | |
| 61 "callFrame": | |
| 62 { | |
| 63 "functionName": "D", | |
| 64 "scriptId": "0", | |
| 65 "url": "a.js", | |
| 66 "lineNumber": 425 | |
| 67 }, | |
| 68 "hitCount": 20, | |
| 69 "callUID": 3000, | |
| 70 "children": [] | |
| 71 } | |
| 72 ] | |
| 73 } | |
| 74 ] | |
| 75 }, | 51 }, |
| 76 { | 52 { |
| 53 "id": 3, |
| 54 "callFrame": |
| 55 { |
| 56 "functionName": "C", |
| 57 "scriptId": "0", |
| 58 "url": "a.js", |
| 59 "lineNumber": 525 |
| 60 }, |
| 61 "hitCount": 100, |
| 62 "children": [4] |
| 63 }, |
| 64 { |
| 65 "id": 4, |
| 66 "callFrame": |
| 67 { |
| 68 "functionName": "D", |
| 69 "scriptId": "0", |
| 70 "url": "a.js", |
| 71 "lineNumber": 425 |
| 72 }, |
| 73 "hitCount": 20, |
| 74 "children": [] |
| 75 }, |
| 76 { |
| 77 "id": 5, |
| 77 "callFrame": | 78 "callFrame": |
| 78 { | 79 { |
| 79 "functionName": "B", | 80 "functionName": "B", |
| 80 "scriptId": "0", | 81 "scriptId": "0", |
| 81 "url": "a.js", | 82 "url": "a.js", |
| 82 "lineNumber": 4662 | 83 "lineNumber": 4662 |
| 83 }, | 84 }, |
| 84 "hitCount": 150, | 85 "hitCount": 150, |
| 85 "callUID": 1002, | 86 "children": [6] |
| 86 "children": [ | 87 }, |
| 88 { |
| 89 "id": 6, |
| 90 "callFrame": |
| 87 { | 91 { |
| 88 "callFrame": | 92 "functionName": "C", |
| 89 { | 93 "scriptId": "0", |
| 90 "functionName": "C", | 94 "url": "a.js", |
| 91 "scriptId": "0", | 95 "lineNumber": 525 |
| 92 "url": "a.js", | 96 }, |
| 93 "lineNumber": 525 | 97 "hitCount": 100, |
| 94 }, | 98 "children": [7] |
| 95 "hitCount": 100, | 99 }, |
| 96 "callUID": 2000, | 100 { |
| 97 "children": [ | 101 "id": 7, |
| 98 { | 102 "callFrame": |
| 99 "callFrame": | 103 { |
| 100 { | 104 "functionName": "D", |
| 101 "functionName": "D", | 105 "scriptId": "0", |
| 102 "scriptId": "0", | 106 "url": "a.js", |
| 103 "url": "a.js", | 107 "lineNumber": 425 |
| 104 "lineNumber": 425 | 108 }, |
| 105 }, | 109 "hitCount": 30, |
| 106 "hitCount": 30, | 110 "children": [] |
| 107 "callUID": 3000, | |
| 108 "children": [] | |
| 109 } | |
| 110 ] | |
| 111 } | |
| 112 ] | |
| 113 } | 111 } |
| 114 ] | 112 ], |
| 115 }, | |
| 116 "startTime": 0, | 113 "startTime": 0, |
| 117 "endTime": 1.000 | 114 "endTime": 1.000 |
| 118 } | 115 } |
| 119 }; | 116 }; |
| 120 var view = new WebInspector.CPUProfileView(profileAndExpectations); | 117 var view = new WebInspector.CPUProfileView(profileAndExpectations); |
| 121 view.viewSelectComboBox.setSelectedIndex(1); | 118 view.viewSelectComboBox.setSelectedIndex(1); |
| 122 view._changeView(); | 119 view._changeView(); |
| 123 var tree = view.profileDataGridTree; | 120 var tree = view.profileDataGridTree; |
| 124 if (!tree) | 121 if (!tree) |
| 125 InspectorTest.addResult("no tree"); | 122 InspectorTest.addResult("no tree"); |
| 126 var node = tree.children[0]; | 123 var node = tree.children[0]; |
| 127 if (!node) | 124 if (!node) |
| 128 InspectorTest.addResult("no node"); | 125 InspectorTest.addResult("no node"); |
| 129 while (node) { | 126 while (node) { |
| 130 InspectorTest.addResult(node.callUID + ": " + node.functionName + " " +
node.self + " " + node.total + " " + node.element().textContent); | 127 InspectorTest.addResult(node.callUID + ": " + node.functionName + " " +
node.self + " " + node.total + " " + node.element().textContent); |
| 131 node = node.traverseNextNode(true, null, true); | 128 node = node.traverseNextNode(true, null, true); |
| 132 } | 129 } |
| 133 InspectorTest.completeProfilerTest(); | 130 InspectorTest.completeProfilerTest(); |
| 134 } | 131 } |
| 135 | 132 |
| 136 </script> | 133 </script> |
| 137 </head> | 134 </head> |
| 138 <body onload="runTest()"> | 135 <body onload="runTest()"> |
| 139 <p> | 136 <p> |
| 140 Tests bottom-up view self and total time calculation in CPU profiler. | 137 Tests bottom-up view self and total time calculation in CPU profiler. |
| 141 </p> | 138 </p> |
| 142 </body> | 139 </body> |
| 143 </html> | 140 </html> |
| OLD | NEW |