Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4455)

Unified Diff: chrome/browser/resources/gpu_internals/timeline_model.js

Issue 7495036: about:gpu support for thread name metadata. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes based on jhawkins Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e50e1347b44c38fd96dfed57aac7a12b9dc84fab 100644
--- a/chrome/browser/resources/gpu_internals/timeline_model.js
+++ b/chrome/browser/resources/gpu_internals/timeline_model.js
@@ -65,6 +65,11 @@ cr.define('gpu', function() {
}
TimelineThread.prototype = {
+ /**
+ * Name of the thread, if present.
+ */
+ name: undefined,
James Hawkins 2011/08/01 18:28:49 Is this intended to be private?
nduca 2011/08/01 20:52:22 Nope, its public. Should I be exposing this via a
James Hawkins 2011/08/01 21:01:24 Hmm, likely though I won't ask you to do that. It'
+
getSubrow: function(i) {
while (i >= this.subRows.length)
this.subRows.push([]);
@@ -84,10 +89,21 @@ cr.define('gpu', function() {
},
updateBounds: function() {
James Hawkins 2011/08/01 18:28:49 Document this method.
nduca 2011/08/01 20:52:22 Done.
- 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 +111,29 @@ cr.define('gpu', function() {
}
};
+ /**
James Hawkins 2011/08/01 18:28:49 Add blank line between methods.
nduca 2011/08/01 20:52:22 Done.
+ * 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) {
James Hawkins 2011/08/01 18:28:49 You could save a lot of indentation by reversing t
James Hawkins 2011/08/01 18:28:49 Space after if.
nduca 2011/08/01 20:52:22 Done.
+ 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
@@ -123,6 +162,7 @@ cr.define('gpu', function() {
*/
function TimelineModel(events) {
this.processes = {};
+ this.importErrors = [];
if (events)
this.importEvents(events);
@@ -144,7 +184,7 @@ cr.define('gpu', function() {
importEvents: function(events) {
// A ptid is a pid and tid joined together x:y fashion, eg 1024:130
// The ptid is a unique key for a thread in the trace.
-
+ this.importErrors = [];
// Threadstate
const numColorIds = 30;
@@ -188,7 +228,7 @@ cr.define('gpu', function() {
sliceID += ';' + event.args[x];
}
if (state.openNonNestedSlices[sliceID])
- console.log('Event ' + sliceID + ' already open.');
+ this.importErrors.push('Event ' + sliceID + ' already open.');
state.openNonNestedSlices[sliceID] = slice;
} else
state.openSlices.push(slice);
@@ -229,12 +269,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 {
+ this.importErrors.push('Unrecognized metadata name: ' + event.name);
+ }
} else {
- throw new Error('Unrecognized event phase: ' + event.ph +
+ this.importErrors.push('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 +315,22 @@ cr.define('gpu', function() {
this.maxTimestamp = this.maxTimestamp + boost;
},
+ /**
+ * Removes threads from the model that have no subrows.
+ */
+ pruneEmptyThreads: function() {
+ 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 || thread.nonNestedSubRows.legnth)
+ prunedThreads.push(thread);
+ }
+ process.threads = prunedThreads;
+ }
+ },
+
updateBounds: function() {
var wmin = Infinity;
var wmax = -wmin;
@@ -275,7 +338,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);
}
« no previous file with comments | « chrome/browser/resources/gpu_internals/timeline.js ('k') | chrome/browser/resources/gpu_internals/timeline_track.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698