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

Unified Diff: tracing/tracing/model/thread.html

Issue 2804043003: [WIP] [DEFINITELY NOT READY TO LAND] Cpu time metric implementation (Closed)
Patch Set: Diff from base Created 3 years, 8 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: tracing/tracing/model/thread.html
diff --git a/tracing/tracing/model/thread.html b/tracing/tracing/model/thread.html
index 736345d5f43b0adcb47f690c3a9a89cdacea8a57..c25f69fd032b7980067a991e266f649abc54dccf 100644
--- a/tracing/tracing/model/thread.html
+++ b/tracing/tracing/model/thread.html
@@ -300,6 +300,27 @@ tr.exportTo('tr.model', function() {
get samples() {
return this.samples_;
},
+
+ /**
+ * Returns a string that denotes the 'type' of a thread used for naming
+ * metrics and histograms.
+ *
+ * It returns the substring from beginning of the string until the first
+ * numeric character or the character '/'. Example:
+ * ThreadName12 -> ThreadName
+ * ThreadName/34123 -> ThreadName
+ * ThreadName1/34123 -> ThreadName
+ */
+ get type() {
+ const re = /^[^0-9|\/]+/;
+ const matches = re.exec(this.name);
+ if (matches && matches[0]) return matches[0];
+
+ // If a thread is named 42GPU, let's not try to find its type.
+ // We should fix the thread name.
+ throw new Error('Could not determine thread type for thread name ' +
+ this.name);
+ }
};
/**

Powered by Google App Engine
This is Rietveld 408576698