Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * @fileoverview TimelineModel is a parsed representation of the | 7 * @fileoverview TimelineModel is a parsed representation of the |
| 8 * TraceEvents obtained from base/trace_event in which the begin-end | 8 * TraceEvents obtained from base/trace_event in which the begin-end |
| 9 * tokens are converted into a hierarchy of processes, threads, | 9 * tokens are converted into a hierarchy of processes, threads, |
| 10 * subrows, and slices. | 10 * subrows, and slices. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 * @constructor | 58 * @constructor |
| 59 */ | 59 */ |
| 60 function TimelineThread(parent, tid) { | 60 function TimelineThread(parent, tid) { |
| 61 this.parent = parent; | 61 this.parent = parent; |
| 62 this.tid = tid; | 62 this.tid = tid; |
| 63 this.subRows = [[]]; | 63 this.subRows = [[]]; |
| 64 this.nonNestedSubRows = []; | 64 this.nonNestedSubRows = []; |
| 65 } | 65 } |
| 66 | 66 |
| 67 TimelineThread.prototype = { | 67 TimelineThread.prototype = { |
| 68 name: undefined, | |
| 69 | |
| 68 getSubrow: function(i) { | 70 getSubrow: function(i) { |
| 69 while (i >= this.subRows.length) | 71 while (i >= this.subRows.length) |
| 70 this.subRows.push([]); | 72 this.subRows.push([]); |
| 71 return this.subRows[i]; | 73 return this.subRows[i]; |
| 72 }, | 74 }, |
| 73 | 75 |
| 74 addNonNestedSlice: function(slice) { | 76 addNonNestedSlice: function(slice) { |
| 75 for (var i = 0; i < this.nonNestedSubRows.length; i++) { | 77 for (var i = 0; i < this.nonNestedSubRows.length; i++) { |
| 76 var currSubRow = this.nonNestedSubRows[i]; | 78 var currSubRow = this.nonNestedSubRows[i]; |
| 77 var lastSlice = currSubRow[currSubRow.length - 1]; | 79 var lastSlice = currSubRow[currSubRow.length - 1]; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 224 |
| 223 // Add the slice to the subSlices array of its parent. | 225 // Add the slice to the subSlices array of its parent. |
| 224 if (state.openSlices.length) { | 226 if (state.openSlices.length) { |
| 225 var parentSlice = state.openSlices[state.openSlices.length - 1]; | 227 var parentSlice = state.openSlices[state.openSlices.length - 1]; |
| 226 parentSlice.slice.subSlices.push(slice); | 228 parentSlice.slice.subSlices.push(slice); |
| 227 } | 229 } |
| 228 } | 230 } |
| 229 } else if (event.ph == 'I') { | 231 } else if (event.ph == 'I') { |
| 230 // TODO(nduca): Implement parsing of immediate events. | 232 // TODO(nduca): Implement parsing of immediate events. |
| 231 console.log('Parsing of I-type events not implemented.'); | 233 console.log('Parsing of I-type events not implemented.'); |
| 234 } else if (event.ph == 'M') { | |
| 235 if (event.name == 'thread_name') { | |
| 236 var thread = this.getProcess(event.pid).getThread(event.tid); | |
| 237 thread.name = event.args.name; | |
| 238 } else { | |
| 239 console.log('Unrecognized metadata name: ' + event.name); | |
| 240 } | |
| 232 } else { | 241 } else { |
| 233 throw new Error('Unrecognized event phase: ' + event.ph + | 242 console.log('Unrecognized event phase: ' + event.ph + |
|
nduca
2011/07/26 09:46:33
stop throwing errors and switch to logging. Unreco
| |
| 234 '(' + event.name + ')'); | 243 '(' + event.name + ')'); |
| 235 } | 244 } |
| 236 } | 245 } |
| 237 | 246 |
| 238 this.updateBounds(); | 247 this.updateBounds(); |
| 239 | 248 |
| 240 // Add end events for any events that are still on the stack. These | 249 // Add end events for any events that are still on the stack. These |
| 241 // are events that were still open when trace was ended, and can often | 250 // are events that were still open when trace was ended, and can often |
| 242 // indicate deadlock behavior. | 251 // indicate deadlock behavior. |
| 243 for (var ptid in threadStateByPTID) { | 252 for (var ptid in threadStateByPTID) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 268 this.maxTimestamp = this.maxTimestamp + boost; | 277 this.maxTimestamp = this.maxTimestamp + boost; |
| 269 }, | 278 }, |
| 270 | 279 |
| 271 updateBounds: function() { | 280 updateBounds: function() { |
| 272 var wmin = Infinity; | 281 var wmin = Infinity; |
| 273 var wmax = -wmin; | 282 var wmax = -wmin; |
| 274 var threads = this.getAllThreads(); | 283 var threads = this.getAllThreads(); |
| 275 for (var tI = 0; tI < threads.length; tI++) { | 284 for (var tI = 0; tI < threads.length; tI++) { |
| 276 var thread = threads[tI]; | 285 var thread = threads[tI]; |
| 277 thread.updateBounds(); | 286 thread.updateBounds(); |
| 278 if (thread.minTimestamp && thread.maxTimestamp) { | 287 if (thread.minTimestamp != undefined && |
|
nduca
2011/07/26 09:46:33
Fix a small issue spotted by tonyg for small trace
| |
| 288 thread.maxTimestamp != undefined) { | |
| 279 wmin = Math.min(wmin, thread.minTimestamp); | 289 wmin = Math.min(wmin, thread.minTimestamp); |
| 280 wmax = Math.max(wmax, thread.maxTimestamp); | 290 wmax = Math.max(wmax, thread.maxTimestamp); |
| 281 } | 291 } |
| 282 } | 292 } |
| 283 this.minTimestamp = wmin; | 293 this.minTimestamp = wmin; |
| 284 this.maxTimestamp = wmax; | 294 this.maxTimestamp = wmax; |
| 285 }, | 295 }, |
| 286 | 296 |
| 287 shiftWorldToMicroseconds: function() { | 297 shiftWorldToMicroseconds: function() { |
| 288 var timeBase = this.minTimestamp; | 298 var timeBase = this.minTimestamp; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 | 330 |
| 321 }; | 331 }; |
| 322 | 332 |
| 323 return { | 333 return { |
| 324 TimelineSlice: TimelineSlice, | 334 TimelineSlice: TimelineSlice, |
| 325 TimelineThread: TimelineThread, | 335 TimelineThread: TimelineThread, |
| 326 TimelineProcess: TimelineProcess, | 336 TimelineProcess: TimelineProcess, |
| 327 TimelineModel: TimelineModel | 337 TimelineModel: TimelineModel |
| 328 }; | 338 }; |
| 329 }); | 339 }); |
| OLD | NEW |