aboutsummaryrefslogtreecommitdiff
path: root/catapult/tracing/tracing/extras/chrome/chrome_user_friendly_category_driver.html
blob: a23d4c647b3f84ffe315782adf8f41b934ffc0d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/base/event.html">
<link rel="import" href="/tracing/base/iteration_helpers.html">

<script>
'use strict';

tr.exportTo('tr.e.chrome', function() {
  var SAME_AS_PARENT = 'same-as-parent';

  var TITLES_FOR_USER_FRIENDLY_CATEGORY = {
    composite: [
      'CompositingInputsUpdater::update',
      'ThreadProxy::SetNeedsUpdateLayers',
      'LayerTreeHost::UpdateLayers::CalcDrawProps',
      'UpdateLayerTree'
    ],

    gc: [
      'minorGC',
      'majorGC',
      'MajorGC',
      'MinorGC',
      'V8.GCScavenger',
      'V8.GCIncrementalMarking',
      'V8.GCIdleNotification',
      'V8.GCContext',
      'V8.GCCompactor',
      'V8GCController::traceDOMWrappers'
    ],

    iframe_creation: [
      'WebLocalFrameImpl::createChildframe'
    ],

    imageDecode: [
      'Decode Image',
      'ImageFrameGenerator::decode',
      'ImageFrameGenerator::decodeAndScale'
    ],

    input: [
      'HitTest',
      'ScrollableArea::scrollPositionChanged',
      'EventHandler::handleMouseMoveEvent'
    ],

    layout: [
      'FrameView::invalidateTree',
      'FrameView::layout',
      'FrameView::performLayout',
      'FrameView::performPostLayoutTasks',
      'FrameView::performPreLayoutTasks',
      'Layer::updateLayerPositionsAfterLayout',
      'Layout',
      'LayoutView::hitTest',
      'ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities',
      'WebViewImpl::layout'
    ],

    parseHTML: [
      'ParseHTML',
      'HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser',
      'HTMLDocumentParser::processParsedChunkFromBackgroundParser'
    ],

    raster: [
      'DisplayListRasterSource::PerformSolidColorAnalysis',
      'Picture::Raster',
      'RasterBufferImpl::Playback',
      'RasterTask',
      'RasterizerTaskImpl::RunOnWorkerThread',
      'SkCanvas::drawImageRect()',
      'SkCanvas::drawPicture()',
      'SkCanvas::drawTextBlob()',
      'TileTaskWorkerPool::PlaybackToMemory'
    ],

    record: [
      'ContentLayerDelegate::paintContents',
      'DeprecatedPaintLayerCompositor::updateIfNeededRecursive',
      'DeprecatedPaintLayerCompositor::updateLayerPositionsAfterLayout',
      'Paint',
      'Picture::Record',
      'PictureLayer::Update',
      'RenderLayer::updateLayerPositionsAfterLayout'
    ],

    style: [
      'CSSParserImpl::parseStyleSheet.parse',
      'CSSParserImpl::parseStyleSheet.tokenize',
      'Document::updateStyle',
      'Document::updateStyleInvalidationIfNeeded',
      'ParseAuthorStyleSheet',
      'RuleSet::addRulesFromSheet',
      'StyleElement::processStyleSheet',
      'StyleEngine::createResolver',
      'StyleSheetContents::parseAuthorStyleSheet',
      'UpdateLayoutTree'
    ],

    script_parse_and_compile: [
      'v8.parseOnBackground',
      'V8.ScriptCompiler'
    ],

    script_execute: [
      'V8.Execute',
      'WindowProxy::initialize'
    ],

    resource_loading: [
      'ResourceFetcher::requestResource',
      'ResourceDispatcher::OnReceivedData',
      'ResourceDispatcher::OnRequestComplete',
      'ResourceDispatcher::OnReceivedResponse',
      'Resource::appendData'
    ],

    // Where do these go?
    renderer_misc: [
      'DecodeFont',
      'ThreadState::completeSweep' // blink_gc
    ],

    // TODO(fmeawad): https://github.com/catapult-project/catapult/issues/2572
    v8_runtime: [
      // Dynamically populated.
    ],

    [SAME_AS_PARENT]: [
      'SyncChannel::Send'
    ]
  };

  var USER_FRIENDLY_CATEGORY_FOR_TITLE = new Map();

  for (var category in TITLES_FOR_USER_FRIENDLY_CATEGORY) {
    TITLES_FOR_USER_FRIENDLY_CATEGORY[category].forEach(function(title) {
      USER_FRIENDLY_CATEGORY_FOR_TITLE.set(title, category);
    });
  }

  var USER_FRIENDLY_CATEGORY_FOR_EVENT_CATEGORY = {
    netlog: 'net',
    overhead: 'overhead',
    startup: 'startup',
    gpu: 'gpu'
  };

  function ChromeUserFriendlyCategoryDriver() {
  }

  ChromeUserFriendlyCategoryDriver.fromEvent = function(event) {
    var userFriendlyCategory =
        USER_FRIENDLY_CATEGORY_FOR_TITLE.get(event.title);
    if (userFriendlyCategory) {
      if (userFriendlyCategory == SAME_AS_PARENT) {
        if (event.parentSlice)
          return ChromeUserFriendlyCategoryDriver.fromEvent(event.parentSlice);
      } else {
        return userFriendlyCategory;
      }
    }

    var eventCategoryParts = tr.b.getCategoryParts(event.category);
    for (var i = 0; i < eventCategoryParts.length; ++i) {
      var eventCategory = eventCategoryParts[i];
      userFriendlyCategory = USER_FRIENDLY_CATEGORY_FOR_EVENT_CATEGORY[
          eventCategory];
      if (userFriendlyCategory)
        return userFriendlyCategory;
    }

    return 'other';
  };

  ChromeUserFriendlyCategoryDriver.ALL_TITLES = ['other'];
  for (var category in TITLES_FOR_USER_FRIENDLY_CATEGORY) {
    if (category === SAME_AS_PARENT)
      continue;
    ChromeUserFriendlyCategoryDriver.ALL_TITLES.push(category);
  }
  for (var category in USER_FRIENDLY_CATEGORY_FOR_EVENT_CATEGORY) {
    ChromeUserFriendlyCategoryDriver.ALL_TITLES.push(category);
  }


  return {
    ChromeUserFriendlyCategoryDriver: ChromeUserFriendlyCategoryDriver
  };
});
</script>