| 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: "simple_trace", | |
| 12 events: [ | |
| 13 {"cat":"PERF","pid":22630,"tid":22630,"ts":826,"ph":"B", | |
| 14 "name":"A long name that doesn't fit but is exceedingly informative", | |
| 15 "args":{}}, | |
| 16 {"cat":"PERF","pid":22630,"tid":22630,"ts":827,"ph":"B", | |
| 17 "name":"Asub with a name that won't fit","args":{}}, | |
| 18 {"cat":"PERF","pid":22630,"tid":22630,"ts":828,"ph":"E", | |
| 19 "name":"Asub","args":{}}, | |
| 20 {"cat":"PERF","pid":22630,"tid":22630,"ts":829,"ph":"B", | |
| 21 "name":"Asub","args":{}}, | |
| 22 {"cat":"PERF","pid":22630,"tid":22630,"ts":832,"ph":"E", | |
| 23 "name":"Asub","args":{}}, | |
| 24 {"cat":"PERF","pid":22630,"tid":22630,"ts":833,"ph":"E", | |
| 25 "name":"","args":{}}, | |
| 26 | |
| 27 {"cat":"PERF","pid":22630,"tid":22630,"ts":835,"ph":"I", | |
| 28 "name":"I1","args":{}}, | |
| 29 {"cat":"PERF","pid":22630,"tid":22630,"ts":837,"ph":"I", | |
| 30 "name":"I2","args":{}}, | |
| 31 | |
| 32 {"cat":"PERF","pid":22630,"tid":22630,"ts":840,"ph":"B", | |
| 33 "name":"A not as long a name","args":{}}, | |
| 34 {"cat":"PERF","pid":22630,"tid":22630,"ts":848,"ph":"E", | |
| 35 "name":"A not as long a name","args":{}}, | |
| 36 | |
| 37 {"cat":"PERF","pid":22630,"tid":22630,"ts":850,"ph":"B", | |
| 38 "name":"B","args":{}}, | |
| 39 {"cat":"PERF","pid":22630,"tid":22630,"ts":854,"ph":"E", | |
| 40 "name":"B","args":{}}, | |
| 41 | |
| 42 {"cat":"PERF","pid":22630,"tid":22631,"ts":827,"ph":"B", | |
| 43 "name":"A","args":{}}, | |
| 44 {"cat":"PERF","pid":22630,"tid":22631,"ts":835,"ph":"I", | |
| 45 "name":"Immediate Three","args":{}}, | |
| 46 {"cat":"PERF","pid":22630,"tid":22631,"ts":845,"ph":"I", | |
| 47 "name":"I4","args":{}}, | |
| 48 {"cat":"PERF","pid":22630,"tid":22631,"ts":854,"ph":"E", | |
| 49 "name":"A","args":{}} | |
| 50 ] | |
| 51 }, | |
| 52 { | |
| 53 name: "nonnested_trace", | |
| 54 events: [ | |
| 55 {'cat':'PERF','pid':22630,'tid':22630,'ts':826,'ph':'B','name':'A','args
':{}}, | |
| 56 {'cat':'PERF','pid':22630,'tid':22630,'ts':827,'ph':'B','name':'Asub','a
rgs':{}}, | |
| 57 {'cat':'PERF','pid':22630,'tid':22630,'ts':829,'ph':'B', | |
| 58 'name':'NonNest','args':{'id':'1','ui-nest':'0'}}, | |
| 59 {'cat':'PERF','pid':22630,'tid':22630,'ts':830,'ph':'B', | |
| 60 'name':'NonNest','args':{'id':'2','ui-nest':'0'}}, | |
| 61 {'cat':'PERF','pid':22630,'tid':22630,'ts':831,'ph':'E', | |
| 62 'name':'Asub','args':{}}, | |
| 63 {'cat':'PERF','pid':22630,'tid':22630,'ts':832,'ph':'E', | |
| 64 'name':'NonNest','args':{'id':'1','ui-nest':'0'}}, | |
| 65 {'cat':'PERF','pid':22630,'tid':22630,'ts':833,'ph':'E', | |
| 66 'name':'NonNest','args':{'id':'2','ui-nest':'0'}}, | |
| 67 {'cat':'PERF','pid':22630,'tid':22630,'ts':834,'ph':'E','name':'A','args
':{}}, | |
| 68 | |
| 69 {'cat':'PERF','pid':22630,'tid':22631,'ts':827,'ph':'B','name':'A','args
':{}}, | |
| 70 {'cat':'PERF','pid':22630,'tid':22631,'ts':854,'ph':'E','name':'A','args
':{}} | |
| 71 ] | |
| 72 }, | |
| 73 { | |
| 74 name: "tall_trace", | |
| 75 events: [ | |
| 76 {"cat":"PERF","pid":22630,"tid":22630,"ts":826,"ph":"B","name":"A","args
":{}}, | |
| 77 {"cat":"PERF","pid":22630,"tid":22630,"ts":827,"ph":"B","name":"Asub","a
rgs":{}}, | |
| 78 {"cat":"PERF","pid":22630,"tid":22630,"ts":828,"ph":"E","name":"Asub","a
rgs":{}}, | |
| 79 {"cat":"PERF","pid":22630,"tid":22630,"ts":829,"ph":"B","name":"Asub","a
rgs":{}}, | |
| 80 {"cat":"PERF","pid":22630,"tid":22630,"ts":832,"ph":"E","name":"Asub","a
rgs":{}}, | |
| 81 {"cat":"PERF","pid":22630,"tid":22630,"ts":833,"ph":"E","name":"","args"
:{}}, | |
| 82 | |
| 83 {"cat":"PERF","pid":22630,"tid":22631,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 84 {"cat":"PERF","pid":22630,"tid":22631,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 85 | |
| 86 {"cat":"PERF","pid":22630,"tid":22632,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 87 {"cat":"PERF","pid":22630,"tid":22632,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 88 | |
| 89 {"cat":"PERF","pid":22630,"tid":22633,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 90 {"cat":"PERF","pid":22630,"tid":22633,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 91 | |
| 92 {"cat":"PERF","pid":22630,"tid":22634,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 93 {"cat":"PERF","pid":22630,"tid":22634,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 94 | |
| 95 {"cat":"PERF","pid":22630,"tid":22635,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 96 {"cat":"PERF","pid":22630,"tid":22635,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 97 | |
| 98 {"cat":"PERF","pid":22630,"tid":22636,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 99 {"cat":"PERF","pid":22630,"tid":22636,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 100 | |
| 101 {"cat":"PERF","pid":22630,"tid":22637,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 102 {"cat":"PERF","pid":22630,"tid":22637,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 103 | |
| 104 {"cat":"PERF","pid":22630,"tid":22638,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 105 {"cat":"PERF","pid":22630,"tid":22638,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 106 | |
| 107 {"cat":"PERF","pid":22630,"tid":22639,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 108 {"cat":"PERF","pid":22630,"tid":22639,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 109 | |
| 110 {"cat":"PERF","pid":22630,"tid":22610,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 111 {"cat":"PERF","pid":22630,"tid":22610,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 112 | |
| 113 {"cat":"PERF","pid":22630,"tid":22611,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 114 {"cat":"PERF","pid":22630,"tid":22611,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 115 | |
| 116 {"cat":"PERF","pid":22630,"tid":22612,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 117 {"cat":"PERF","pid":22630,"tid":22612,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 118 | |
| 119 {"cat":"PERF","pid":22630,"tid":22613,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 120 {"cat":"PERF","pid":22630,"tid":22613,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 121 | |
| 122 {"cat":"PERF","pid":22630,"tid":22614,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 123 {"cat":"PERF","pid":22630,"tid":22614,"ts":848,"ph":"E","name":"A","args
":{}}, | |
| 124 | |
| 125 {"cat":"PERF","pid":22630,"tid":22615,"ts":840,"ph":"B","name":"A","args
":{}}, | |
| 126 {"cat":"PERF","pid":22630,"tid":22615,"ts":848,"ph":"E","name":"A","args
":{}} | |
| 127 ] | |
| 128 }, | |
| 129 { | |
| 130 name: "huge_trace", | |
| 131 events_url: "./tests/huge_trace.json" | |
| 132 } | |
| 133 ]; | |
| 134 | |
| 135 // Create UI for controlling the test harness | |
| 136 var selectEl = document.createElement("select"); | |
| 137 for (var i = 0; i < dataSets.length; ++i) { | |
| 138 var optionEl = document.createElement("option"); | |
| 139 optionEl.textContent = dataSets[i].name; | |
| 140 optionEl.dataSet = dataSets[i]; | |
| 141 selectEl.appendChild(optionEl); | |
| 142 } | |
| 143 selectEl.addEventListener("change", function() { | |
| 144 tracingController.beginTracing(); | |
| 145 }); | |
| 146 selectEl.addEventListener("keydown", function() { | |
| 147 window.setTimeout(function() { | |
| 148 tracingController.beginTracing(); | |
| 149 }, 0); | |
| 150 }); | |
| 151 | |
| 152 var controlEl = document.createElement("div"); | |
| 153 var textEl = document.createElement("span"); | |
| 154 textEl.textContent = "Trace:"; | |
| 155 controlEl.appendChild(textEl); | |
| 156 controlEl.appendChild(selectEl); | |
| 157 | |
| 158 document.querySelector("#debug-div").appendChild(controlEl, | |
| 159 document.body.firstChild); | |
| 160 | |
| 161 return { | |
| 162 tracingControllerTestHarness : { | |
| 163 beginTracing: function() { | |
| 164 var dataSet = dataSets[selectEl.selectedIndex]; | |
| 165 if (dataSet.events) { | |
| 166 window.setTimeout(function() { | |
| 167 tracingController.onTraceDataCollected(dataSet.events); | |
| 168 tracingController.endTracing(); | |
| 169 window.setTimeout(function() { | |
| 170 tracingController.onEndTracingComplete(); | |
| 171 },0); | |
| 172 }, 0); | |
| 173 } else { | |
| 174 var req = new XMLHttpRequest(); | |
| 175 req.open('GET', "./gpu_internals/" + dataSet.events_url, true); | |
| 176 req.onreadystatechange = function (aEvt) { | |
| 177 if (req.readyState == 4) { | |
| 178 tracingController.endTracing(); | |
| 179 window.setTimeout(function() { | |
| 180 if(req.status == 200) { | |
| 181 var resp = JSON.parse(req.responseText); | |
| 182 if (resp.traceEvents) | |
| 183 tracingController.onTraceDataCollected(resp.traceEvents); | |
| 184 else | |
| 185 tracingController.onTraceDataCollected(resp); | |
| 186 } else { | |
| 187 console.log("collection failed."); | |
| 188 } | |
| 189 tracingController.onEndTracingComplete(); | |
| 190 }, 0); | |
| 191 } | |
| 192 }; | |
| 193 req.send(null); | |
| 194 } | |
| 195 }, | |
| 196 | |
| 197 endTracing: function() { | |
| 198 } | |
| 199 } | |
| 200 }; | |
| 201 }); | |
| OLD | NEW |