OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 cr.define('gpu', function() { | |
5 var dataSets = [ | |
6 { | |
7 name: "big_trace", | |
8 events_url: "./tests/big_trace.json" | |
9 }, | |
10 { | |
11 name: "trivial_trace", | |
12 events: [ | |
13 {"name":"a","args":{},"pid":52,"ts":9524,"cat":"foo","tid":53,"ph":"B"}, | |
14 {"name":"a","args":{},"pid":52,"ts":9560,"cat":"foo","tid":53,"ph":"E"}, | |
15 {"name":"b","args":{},"pid":52,"ts":9629,"cat":"foo","tid":53,"ph":"B"}, | |
16 {"name":"b","args":{},"pid":52,"ts":9631,"cat":"foo","tid":53,"ph":"E"} | |
17 ] | |
18 }, | |
19 { | |
20 name: "simple_trace", | |
21 events: [ | |
22 {"cat":"PERF","pid":22630,"tid":22630,"ts":826,"ph":"B", | |
23 "name":"A long name that doesn't fit but is exceedingly informative", | |
24 "args":{}}, | |
25 {"cat":"PERF","pid":22630,"tid":22630,"ts":827,"ph":"B", | |
26 "name":"Asub with a name that won't fit","args":{}}, | |
27 {"cat":"PERF","pid":22630,"tid":22630,"ts":828,"ph":"E", | |
28 "name":"Asub","args":{}}, | |
29 {"cat":"PERF","pid":22630,"tid":22630,"ts":829,"ph":"B", | |
30 "name":"Asub","args":{}}, | |
31 {"cat":"PERF","pid":22630,"tid":22630,"ts":832,"ph":"E", | |
32 "name":"Asub","args":{}}, | |
33 {"cat":"PERF","pid":22630,"tid":22630,"ts":833,"ph":"E", | |
34 "name":"","args":{}}, | |
35 | |
36 {"cat":"PERF","pid":22630,"tid":22630,"ts":835,"ph":"I", | |
37 "name":"I1","args":{}}, | |
38 {"cat":"PERF","pid":22630,"tid":22630,"ts":837,"ph":"I", | |
39 "name":"I2","args":{}}, | |
40 | |
41 {"cat":"PERF","pid":22630,"tid":22630,"ts":840,"ph":"B", | |
42 "name":"A not as long a name","args":{}}, | |
43 {"cat":"PERF","pid":22630,"tid":22630,"ts":848,"ph":"E", | |
44 "name":"A not as long a name","args":{}}, | |
45 | |
46 {"cat":"PERF","pid":22630,"tid":22630,"ts":850,"ph":"B", | |
47 "name":"B","args":{}}, | |
48 {"cat":"PERF","pid":22630,"tid":22630,"ts":854,"ph":"E", | |
49 "name":"B","args":{}}, | |
50 | |
51 {"cat":"PERF","pid":22630,"tid":22631,"ts":827,"ph":"B", | |
52 "name":"A","args":{}}, | |
53 {"cat":"PERF","pid":22630,"tid":22631,"ts":835,"ph":"I", | |
54 "name":"Immediate Three","args":{}}, | |
55 {"cat":"PERF","pid":22630,"tid":22631,"ts":845,"ph":"I", | |
56 "name":"I4","args":{}}, | |
57 {"cat":"PERF","pid":22630,"tid":22631,"ts":854,"ph":"E", | |
58 "name":"A","args":{}}, | |
59 | |
60 {"cat":"__metadata","pid":22630,"tid":22630,"ts":0,"ph":"M", | |
61 "name":"thread_name","args":{"name": "threadA"}}, | |
62 {"cat":"__metadata","pid":22630,"tid":22631,"ts":0,"ph":"M", | |
63 "name":"thread_name","args":{"name": "threadB"}}, | |
64 {"cat":"__metadata","pid":22630,"tid":22632,"ts":0,"ph":"M", | |
65 "name":"thread_name","args":{"name": "threadC"}} | |
66 ] | |
67 }, | |
68 { | |
69 name: "nonnested_trace", | |
70 events: [ | |
71 {'cat':'PERF','pid':22630,'tid':22630,'ts':826,'ph':'B', | |
72 'name':'A','args':{}}, | |
73 {'cat':'PERF','pid':22630,'tid':22630,'ts':827,'ph':'B', | |
74 'name':'Asub','args':{}}, | |
75 {'cat':'PERF','pid':22630,'tid':22630,'ts':829,'ph':'B', | |
76 'name':'NonNest','args':{'id':'1','ui-nest':'0'}}, | |
77 {'cat':'PERF','pid':22630,'tid':22630,'ts':830,'ph':'B', | |
78 'name':'NonNest','args':{'id':'2','ui-nest':'0'}}, | |
79 {'cat':'PERF','pid':22630,'tid':22630,'ts':831,'ph':'E', | |
80 'name':'Asub','args':{}}, | |
81 {'cat':'PERF','pid':22630,'tid':22630,'ts':832,'ph':'E', | |
82 'name':'NonNest','args':{'id':'1','ui-nest':'0'}}, | |
83 {'cat':'PERF','pid':22630,'tid':22630,'ts':833,'ph':'E', | |
84 'name':'NonNest','args':{'id':'2','ui-nest':'0'}}, | |
85 {'cat':'PERF','pid':22630,'tid':22630,'ts':834,'ph':'E', | |
86 'name':'A','args':{}}, | |
87 | |
88 {'cat':'PERF','pid':22630,'tid':22631,'ts':827,'ph':'B', | |
89 'name':'A','args':{}}, | |
90 {'cat':'PERF','pid':22630,'tid':22631,'ts':854,'ph':'E', | |
91 'name':'A','args':{}} | |
92 ] | |
93 }, | |
94 { | |
95 name: "tall_trace", | |
96 events: [ | |
97 {"cat":"X","pid":30,"tid":30,"ts":826,"ph":"B","name":"A","args":{}}, | |
98 {"cat":"X","pid":30,"tid":30,"ts":827,"ph":"B","name":"Asub","args":{}}, | |
99 {"cat":"X","pid":30,"tid":30,"ts":828,"ph":"E","name":"Asub","args":{}}, | |
100 {"cat":"X","pid":30,"tid":30,"ts":829,"ph":"B","name":"Asub","args":{}}, | |
101 {"cat":"X","pid":30,"tid":30,"ts":832,"ph":"E","name":"Asub","args":{}}, | |
102 {"cat":"X","pid":30,"tid":30,"ts":833,"ph":"E","name":"","args":{}}, | |
103 | |
104 {"cat":"X","pid":30,"tid":31,"ts":840,"ph":"B","name":"A","args":{}}, | |
105 {"cat":"X","pid":30,"tid":31,"ts":848,"ph":"E","name":"A","args":{}}, | |
106 | |
107 {"cat":"X","pid":30,"tid":32,"ts":840,"ph":"B","name":"A","args":{}}, | |
108 {"cat":"X","pid":30,"tid":32,"ts":848,"ph":"E","name":"A","args":{}}, | |
109 | |
110 {"cat":"X","pid":30,"tid":33,"ts":840,"ph":"B","name":"A","args":{}}, | |
111 {"cat":"X","pid":30,"tid":33,"ts":848,"ph":"E","name":"A","args":{}}, | |
112 | |
113 {"cat":"X","pid":30,"tid":34,"ts":840,"ph":"B","name":"A","args":{}}, | |
114 {"cat":"X","pid":30,"tid":34,"ts":848,"ph":"E","name":"A","args":{}}, | |
115 | |
116 {"cat":"X","pid":30,"tid":35,"ts":840,"ph":"B","name":"A","args":{}}, | |
117 {"cat":"X","pid":30,"tid":35,"ts":848,"ph":"E","name":"A","args":{}}, | |
118 | |
119 {"cat":"X","pid":30,"tid":36,"ts":840,"ph":"B","name":"A","args":{}}, | |
120 {"cat":"X","pid":30,"tid":36,"ts":848,"ph":"E","name":"A","args":{}}, | |
121 | |
122 {"cat":"X","pid":30,"tid":37,"ts":840,"ph":"B","name":"A","args":{}}, | |
123 {"cat":"X","pid":30,"tid":37,"ts":848,"ph":"E","name":"A","args":{}}, | |
124 | |
125 {"cat":"X","pid":30,"tid":38,"ts":840,"ph":"B","name":"A","args":{}}, | |
126 {"cat":"X","pid":30,"tid":38,"ts":848,"ph":"E","name":"A","args":{}}, | |
127 | |
128 {"cat":"X","pid":30,"tid":39,"ts":840,"ph":"B","name":"A","args":{}}, | |
129 {"cat":"X","pid":30,"tid":39,"ts":848,"ph":"E","name":"A","args":{}}, | |
130 | |
131 {"cat":"X","pid":30,"tid":10,"ts":840,"ph":"B","name":"A","args":{}}, | |
132 {"cat":"X","pid":30,"tid":10,"ts":848,"ph":"E","name":"A","args":{}}, | |
133 | |
134 {"cat":"X","pid":31,"tid":11,"ts":840,"ph":"B","name":"A","args":{}}, | |
135 {"cat":"X","pid":31,"tid":11,"ts":848,"ph":"E","name":"A","args":{}}, | |
136 | |
137 {"cat":"X","pid":30,"tid":12,"ts":840,"ph":"B","name":"A","args":{}}, | |
138 {"cat":"X","pid":30,"tid":12,"ts":848,"ph":"E","name":"A","args":{}}, | |
139 | |
140 {"cat":"X","pid":30,"tid":13,"ts":840,"ph":"B","name":"A","args":{}}, | |
141 {"cat":"X","pid":30,"tid":13,"ts":848,"ph":"E","name":"A","args":{}}, | |
142 | |
143 {"cat":"X","pid":30,"tid":14,"ts":840,"ph":"B","name":"A","args":{}}, | |
144 {"cat":"X","pid":30,"tid":14,"ts":848,"ph":"E","name":"A","args":{}}, | |
145 | |
146 {"cat":"X","pid":30,"tid":15,"ts":840,"ph":"B","name":"A","args":{}}, | |
147 {"cat":"X","pid":30,"tid":15,"ts":848,"ph":"E","name":"A","args":{}}, | |
148 | |
149 {"cat":"__metadata","pid":30,"tid":14,"ts":0,"ph":"M", | |
150 "name":"thread_name","args":{"name": "threadB"}}, | |
151 {"cat":"__metadata","pid":30,"tid":15,"ts":0,"ph":"M", | |
152 "name":"thread_name","args":{"name": "threadA"}} | |
153 ] | |
154 }, | |
155 { | |
156 name: "huge_trace", | |
157 events_url: "./tests/huge_trace.json" | |
158 } | |
159 ]; | |
160 | |
161 // Create UI for controlling the test harness | |
162 var selectEl = document.createElement("select"); | |
163 for (var i = 0; i < dataSets.length; ++i) { | |
164 var optionEl = document.createElement("option"); | |
165 optionEl.textContent = dataSets[i].name; | |
166 optionEl.dataSet = dataSets[i]; | |
167 selectEl.appendChild(optionEl); | |
168 } | |
169 selectEl.addEventListener("change", function() { | |
170 tracingController.beginTracing(); | |
171 }); | |
172 selectEl.addEventListener("keydown", function() { | |
173 window.setTimeout(function() { | |
174 tracingController.beginTracing(); | |
175 }, 0); | |
176 }); | |
177 | |
178 var controlEl = document.createElement("div"); | |
179 var textEl = document.createElement("span"); | |
180 textEl.textContent = "Trace:"; | |
181 controlEl.appendChild(textEl); | |
182 controlEl.appendChild(selectEl); | |
183 | |
184 document.querySelector("#debug-div").appendChild(controlEl, | |
185 document.body.firstChild); | |
186 | |
187 return { | |
188 tracingControllerTestHarness : { | |
189 beginTracing: function() { | |
190 var dataSet = dataSets[selectEl.selectedIndex]; | |
191 if (dataSet.events) { | |
192 window.setTimeout(function() { | |
193 tracingController.onTraceDataCollected(dataSet.events); | |
194 tracingController.endTracing(); | |
195 window.setTimeout(function() { | |
196 tracingController.onEndTracingComplete(); | |
197 },0); | |
198 }, 0); | |
199 } else { | |
200 var req = new XMLHttpRequest(); | |
201 req.open('GET', "./gpu_internals/" + dataSet.events_url, true); | |
202 req.onreadystatechange = function (aEvt) { | |
203 if (req.readyState == 4) { | |
204 tracingController.endTracing(); | |
205 window.setTimeout(function() { | |
206 if(req.status == 200) { | |
207 var resp = JSON.parse(req.responseText); | |
208 if (resp.traceEvents) | |
209 tracingController.onTraceDataCollected(resp.traceEvents); | |
210 else | |
211 tracingController.onTraceDataCollected(resp); | |
212 } else { | |
213 console.log("collection failed."); | |
214 } | |
215 tracingController.onEndTracingComplete(); | |
216 }, 0); | |
217 } | |
218 }; | |
219 req.send(null); | |
220 } | |
221 }, | |
222 | |
223 endTracing: function() { | |
224 } | |
225 } | |
226 }; | |
227 }); | |
OLD | NEW |