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

Side by Side Diff: perf_insights/perf_insights/mappers/thread_grouping.html

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/tracing/base/iteration_helpers.html">
9 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html">
10 <link rel="import" href="/tracing/value/value.html">
11
12 <script>
13 'use strict';
14
15 tr.exportTo('pi.m', function() {
16 function ThreadGrouping() {
17 this.groupNameForThreadGUID_ = {};
18 }
19
20 ThreadGrouping.prototype = {
21 autoInitUsingHelpers: function(model) {
22 // Everything is 'other' by default.
23 model.getAllThreads().forEach(function(thread) {
24 this.groupNameForThreadGUID_[thread.guid] = 'Other';
25 }, this);
26 var chromeHelper = model.getOrCreateHelper(
27 tr.model.helpers.ChromeModelHelper);
28
29 if (chromeHelper) {
30 var browserHelper = chromeHelper.browserHelper;
31 this.addThreadsInProcessToGroup_(browserHelper.process, 'Browser');
32
33 var gpuHelper = chromeHelper.gpuHelper;
34 if (gpuHelper) {
35 this.addThreadsInProcessToGroup_(gpuHelper.process, 'GPU');
36 }
37
38 for (var pid in chromeHelper.rendererHelpers) {
39 var rendererHelper = chromeHelper.rendererHelpers[pid];
40 this.addThreadsInProcessToGroup_(rendererHelper.process, 'Renderer');
41 }
42
43 // TODO(nduca): Modify the helpers to detect plugin processes
44 // and include those in separate processes.
45 }
46
47 // It would be very easy to add processes recognized by android helper
48 // here, too.
49 },
50
51 getGroupNameForThread: function(thread) {
52 if (!(thread instanceof tr.model.EventContainer))
53 return 'error';
54
55 var groupName = this.groupNameForThreadGUID_[thread.guid];
56 if (groupName === undefined)
57 return 'Other';
58 return groupName;
59 },
60
61 getGroupNameForEvent: function(event) {
62 var parentContainer = event.parentContainer;
63 if (parentContainer === undefined)
64 return 'Unknown';
65 return this.getGroupNameForThread(parentContainer);
66 },
67
68 addThreadsInProcessToGroup_: function(process, groupName,
69 opt_predicate, opt_this) {
70 var predicate = opt_predicate || tr.b.identity;
71
72 for (var tid in process.threads) {
73 var thread = process.threads[tid];
74 if (predicate.call(opt_this, thread))
75 this.groupNameForThreadGUID_[thread.guid] = groupName;
76 }
77 },
78
79 divideEventSetIntoSubGroups: function(eventSet) {
80 var resultingEventSets = {
81 other: new tr.model.EventSet()
82 };
83 tr.b.iterItems(this.groupNameForThreadGUID_, function(guid, groupName) {
84 if (resultingEventSets[groupName] !== undefined)
85 return;
86 resultingEventSets[groupName] = new tr.model.EventSet();
87 });
88
89 eventSet.forEach(function(event) {
90 var parentContainer = event.parentContainer;
91 if (parentContainer === undefined)
92 return;
93
94 if (!(parentContainer instanceof tr.model.EventContainer))
95 return;
96
97 var groupName = this.groupNameForThreadGUID_[parentContainer.guid];
98 if (groupName === undefined)
99 groupName = 'Other';
100 resultingEventSets[groupName].push(event);
101
102 }, this);
103
104 return resultingEventSets;
105 }
106 };
107
108 return {
109 ThreadGrouping: ThreadGrouping
110 };
111 });
112 </script>
OLDNEW
« no previous file with comments | « perf_insights/perf_insights/mappers/test_mapper.html ('k') | perf_insights/perf_insights/mappers/thread_grouping_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698