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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 sliceID += ';' + event.args[x]; | 276 sliceID += ';' + event.args[x]; |
277 var slice = state.openNonNestedSlices[sliceID]; | 277 var slice = state.openNonNestedSlices[sliceID]; |
278 if (!slice) | 278 if (!slice) |
279 return; | 279 return; |
280 slice.slice.duration = event.ts - slice.slice.start; | 280 slice.slice.duration = event.ts - slice.slice.start; |
281 if (event.uts) | 281 if (event.uts) |
282 slice.durationInUserTime = event.uts - slice.slice.startInUserTime; | 282 slice.durationInUserTime = event.uts - slice.slice.startInUserTime; |
283 | 283 |
284 // Store the slice in a non-nested subrow. | 284 // Store the slice in a non-nested subrow. |
285 var thread = self.getOrCreateProcess(event.pid). | 285 var thread = self.getOrCreateProcess(event.pid). |
286 getOrCreateThread(event.tid); | 286 getOrCreateThread(event.tid); |
James Hawkins
2011/11/11 23:37:40
nit: Indentation for wrapped lines is 4 spaces fro
nduca
2011/11/12 01:28:27
Done.
| |
287 thread.addNonNestedSlice(slice.slice); | 287 thread.addNonNestedSlice(slice.slice); |
288 delete state.openNonNestedSlices[name]; | 288 delete state.openNonNestedSlices[name]; |
289 } else { | 289 } else { |
290 if (state.openSlices.length == 0) { | 290 if (state.openSlices.length == 0) { |
291 // Ignore E events that are unmatched. | 291 // Ignore E events that are unmatched. |
292 return; | 292 return; |
293 } | 293 } |
294 var slice = state.openSlices.pop().slice; | 294 var slice = state.openSlices.pop().slice; |
295 slice.duration = event.ts - slice.start; | 295 slice.duration = event.ts - slice.start; |
296 if (event.uts) | 296 if (event.uts) |
297 slice.durationInUserTime = event.uts - slice.startInUserTime; | 297 slice.durationInUserTime = event.uts - slice.startInUserTime; |
298 | 298 |
299 // Store the slice on the correct subrow. | 299 // Store the slice on the correct subrow. |
300 var thread = self.getOrCreateProcess(event.pid) | 300 var thread = self.getOrCreateProcess(event.pid) |
301 .getOrCreateThread(event.tid); | 301 .getOrCreateThread(event.tid); |
302 var subRowIndex = state.openSlices.length; | 302 var subRowIndex = state.openSlices.length; |
303 thread.getSubrow(subRowIndex).push(slice); | 303 thread.getSubrow(subRowIndex).push(slice); |
304 | 304 |
305 // Add the slice to the subSlices array of its parent. | 305 // Add the slice to the subSlices array of its parent. |
306 if (state.openSlices.length) { | 306 if (state.openSlices.length) { |
307 var parentSlice = state.openSlices[state.openSlices.length - 1]; | 307 var parentSlice = state.openSlices[state.openSlices.length - 1]; |
308 parentSlice.slice.subSlices.push(slice); | 308 parentSlice.slice.subSlices.push(slice); |
309 } | 309 } |
310 } | 310 } |
311 } | 311 } |
(...skipping 19 matching lines...) Expand all Loading... | |
331 } else if (event.ph == 'M') { | 331 } else if (event.ph == 'M') { |
332 if (event.name == 'thread_name') { | 332 if (event.name == 'thread_name') { |
333 var thread = this.getOrCreateProcess(event.pid) | 333 var thread = this.getOrCreateProcess(event.pid) |
334 .getOrCreateThread(event.tid); | 334 .getOrCreateThread(event.tid); |
335 thread.name = event.args.name; | 335 thread.name = event.args.name; |
336 } else { | 336 } else { |
337 this.importErrors.push('Unrecognized metadata name: ' + event.name); | 337 this.importErrors.push('Unrecognized metadata name: ' + event.name); |
338 } | 338 } |
339 } else { | 339 } else { |
340 this.importErrors.push('Unrecognized event phase: ' + event.ph + | 340 this.importErrors.push('Unrecognized event phase: ' + event.ph + |
341 '(' + event.name + ')'); | 341 '(' + event.name + ')'); |
342 } | 342 } |
343 } | 343 } |
344 this.pruneEmptyThreads(); | 344 this.pruneEmptyThreads(); |
345 this.updateBounds(); | 345 this.updateBounds(); |
346 | 346 |
347 // Add end events for any events that are still on the stack. These | 347 // Add end events for any events that are still on the stack. These |
348 // are events that were still open when trace was ended, and can often | 348 // are events that were still open when trace was ended, and can often |
349 // indicate deadlock behavior. | 349 // indicate deadlock behavior. |
350 for (var ptid in threadStateByPTID) { | 350 for (var ptid in threadStateByPTID) { |
351 var state = threadStateByPTID[ptid]; | 351 var state = threadStateByPTID[ptid]; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 }; | 450 }; |
451 | 451 |
452 return { | 452 return { |
453 getStringHash: getStringHash, | 453 getStringHash: getStringHash, |
454 TimelineSlice: TimelineSlice, | 454 TimelineSlice: TimelineSlice, |
455 TimelineThread: TimelineThread, | 455 TimelineThread: TimelineThread, |
456 TimelineProcess: TimelineProcess, | 456 TimelineProcess: TimelineProcess, |
457 TimelineModel: TimelineModel | 457 TimelineModel: TimelineModel |
458 }; | 458 }; |
459 }); | 459 }); |
OLD | NEW |