Chromium Code Reviews| Index: chrome/browser/resources/gpu_internals/timeline_model.js |
| diff --git a/chrome/browser/resources/gpu_internals/timeline_model.js b/chrome/browser/resources/gpu_internals/timeline_model.js |
| index 1739e3c195685dc44f5c6434c218a9145a2c5774..9906d314ae8b176f11b54ea001193a0d1e0e41a9 100644 |
| --- a/chrome/browser/resources/gpu_internals/timeline_model.js |
| +++ b/chrome/browser/resources/gpu_internals/timeline_model.js |
| @@ -65,6 +65,8 @@ cr.define('gpu', function() { |
| } |
| TimelineThread.prototype = { |
| + name: undefined, |
|
James Hawkins
2011/07/28 21:52:15
Document var. If it's intended to be private, appe
nduca
2011/08/01 01:22:45
Done.
|
| + |
| getSubrow: function(i) { |
| while (i >= this.subRows.length) |
| this.subRows.push([]); |
| @@ -84,10 +86,21 @@ cr.define('gpu', function() { |
| }, |
| updateBounds: function() { |
| - var slices = this.subRows[0]; |
| - if (slices.length != 0) { |
| - this.minTimestamp = slices[0].start; |
| - this.maxTimestamp = slices[slices.length - 1].end; |
| + var values = []; |
| + var slices; |
| + if (this.subRows[0].length != 0) { |
| + slices = this.subRows[0]; |
| + values.push(slices[0].start); |
| + values.push(slices[slices.length - 1].end); |
| + } |
| + for (var i = 0; i < this.nonNestedSubRows.length; ++i) { |
| + slices = this.nonNestedSubRows[i]; |
| + values.push(slices[0].start); |
| + values.push(slices[slices.length - 1].end); |
| + } |
| + if (values.length) { |
| + this.minTimestamp = Math.min.apply(Math, values); |
| + this.maxTimestamp = Math.max.apply(Math, values); |
| } else { |
| this.minTimestamp = undefined; |
| this.maxTimestamp = undefined; |
| @@ -95,6 +108,29 @@ cr.define('gpu', function() { |
| } |
| }; |
| + /** |
| + * Comparison between threads that orders first by pid, |
| + * then by names, then by tid. |
| + */ |
| + TimelineThread.compare = function(x,y) { |
| + if(x.parent.pid == y.parent.pid) { |
| + if (x.name && y.name) { |
| + var tmp = x.name.localeCompare(y.name); |
| + if (tmp == 0) |
| + return x.tid - y.tid; |
| + return tmp; |
| + } else if(x.name) { |
| + return -1; |
| + } else if(y.name){ |
| + return 1; |
| + } else { |
| + return x.tid - y.tid; |
| + } |
| + } else { |
| + return x.parent.pid - y.parent.pid; |
| + } |
| + }; |
| + |
| /** |
| * The TimelineProcess represents a single process in the |
| @@ -229,12 +265,19 @@ cr.define('gpu', function() { |
| } else if (event.ph == 'I') { |
| // TODO(nduca): Implement parsing of immediate events. |
| console.log('Parsing of I-type events not implemented.'); |
| + } else if (event.ph == 'M') { |
| + if (event.name == 'thread_name') { |
| + var thread = this.getProcess(event.pid).getThread(event.tid); |
| + thread.name = event.args.name; |
| + } else { |
| + console.log('Unrecognized metadata name: ' + event.name); |
|
James Hawkins
2011/07/28 21:52:15
Remove console spam here and elsewhere.
nduca
2011/08/01 01:22:45
Done.
|
| + } |
| } else { |
| - throw new Error('Unrecognized event phase: ' + event.ph + |
| + console.log('Unrecognized event phase: ' + event.ph + |
| '(' + event.name + ')'); |
| } |
| } |
| - |
| + this.pruneEmptyThreads(); |
| this.updateBounds(); |
| // Add end events for any events that are still on the stack. These |
| @@ -268,6 +311,19 @@ cr.define('gpu', function() { |
| this.maxTimestamp = this.maxTimestamp + boost; |
| }, |
| + pruneEmptyThreads: function() { |
|
James Hawkins
2011/07/28 21:52:15
Document method.
nduca
2011/08/01 01:22:45
Done.
|
| + for (var pid in this.processes) { |
| + var process = this.processes[pid]; |
| + var prunedThreads = []; |
| + for (var tid in process.threads) { |
| + var thread = process.threads[tid]; |
| + if (thread.subRows[0].length) |
| + prunedThreads.push(thread); |
| + } |
| + process.threads = prunedThreads; |
| + } |
| + }, |
| + |
| updateBounds: function() { |
| var wmin = Infinity; |
| var wmax = -wmin; |
| @@ -275,7 +331,8 @@ cr.define('gpu', function() { |
| for (var tI = 0; tI < threads.length; tI++) { |
| var thread = threads[tI]; |
| thread.updateBounds(); |
| - if (thread.minTimestamp && thread.maxTimestamp) { |
| + if (thread.minTimestamp != undefined && |
| + thread.maxTimestamp != undefined) { |
| wmin = Math.min(wmin, thread.minTimestamp); |
| wmax = Math.max(wmax, thread.maxTimestamp); |
| } |