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

Side by Side Diff: tracing/tracing/metrics/system_health/long_tasks_metric.html

Issue 2133963002: Implement Composition.buildFromEvents() (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: fix composition-span 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import"
eakuefner 2016/07/12 16:18:48 nit: there isn't an 80char limit in HTML, so just
9 href="/tracing/extras/chrome/chrome_user_friendly_category_driver.html">
8 <link rel="import" href="/tracing/metrics/metric_registry.html"> 10 <link rel="import" href="/tracing/metrics/metric_registry.html">
9 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> 11 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html">
10 <link rel="import" href="/tracing/value/numeric.html"> 12 <link rel="import" href="/tracing/value/numeric.html">
11 <link rel="import" href="/tracing/value/value.html"> 13 <link rel="import" href="/tracing/value/value.html">
12 14
13 <script> 15 <script>
14 'use strict'; 16 'use strict';
15 17
16 tr.exportTo('tr.metrics.sh', function() { 18 tr.exportTo('tr.metrics.sh', function() {
17 var LONG_TASK_MS = 50; 19 var LONG_TASK_MS = 50;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 function(rendererHelper) { 63 function(rendererHelper) {
62 if (!rendererHelper.mainThread) 64 if (!rendererHelper.mainThread)
63 return; 65 return;
64 cb.call(opt_this, rendererHelper.mainThread); 66 cb.call(opt_this, rendererHelper.mainThread);
65 }); 67 });
66 } 68 }
67 69
68 var LONG_TASK_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( 70 var LONG_TASK_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear(
69 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, 71 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter,
70 tr.b.Range.fromExplicitRange(LONG_TASK_MS, LONGEST_TASK_MS), 50); 72 tr.b.Range.fromExplicitRange(LONG_TASK_MS, LONGEST_TASK_MS), 50);
73 var SLICE_NUMERIC_BUILDER = tr.v.NumericBuilder.createExponential(
eakuefner 2016/07/12 16:18:48 Why exponential? Comment perhaps?
74 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter,
75 tr.b.Range.fromExplicitRange(0.1, LONGEST_TASK_MS), 50);
71 76
72 /** 77 /**
73 * This metric directly measures long tasks on renderer main threads. 78 * This metric directly measures long tasks on renderer main threads.
74 * This metric requires only the 'toplevel' tracing category. 79 * This metric requires only the 'toplevel' tracing category.
75 * 80 *
76 * @param {!tr.v.ValueSet} values 81 * @param {!tr.v.ValueSet} values
77 * @param {!tr.model.Model} model 82 * @param {!tr.model.Model} model
78 * @param {!Object=} opt_options 83 * @param {!Object=} opt_options
79 */ 84 */
80 function longTasksMetric(values, model, opt_options) { 85 function longTasksMetric(values, model, opt_options) {
81 var rangeOfInterest = opt_options ? opt_options.rangeOfInterest : undefined; 86 var rangeOfInterest = opt_options ? opt_options.rangeOfInterest : undefined;
82 var longTaskNumeric = LONG_TASK_NUMERIC_BUILDER.build(); 87 var longTaskNumeric = LONG_TASK_NUMERIC_BUILDER.build();
88 var slices = new tr.model.EventSet();
83 iterateRendererMainThreads(model, function(thread) { 89 iterateRendererMainThreads(model, function(thread) {
84 iterateLongTopLevelTasksOnThreadInRange( 90 iterateLongTopLevelTasksOnThreadInRange(
85 thread, rangeOfInterest, function(task) { 91 thread, rangeOfInterest, function(task) {
86 longTaskNumeric.add(task.duration, 92 longTaskNumeric.add(task.duration,
87 new tr.v.d.RelatedEventSet([task])); 93 new tr.v.d.RelatedEventSet([task]));
94 slices.push(task);
95 slices.addEventSet(task.descendentSlices);
88 }); 96 });
89 }); 97 });
90 var options = {description: 'durations of long tasks'}; 98 var options = {description: 'durations of long tasks'};
91 values.addValue(new tr.v.NumericValue( 99 var longTaskValue = new tr.v.NumericValue(
92 'long tasks', longTaskNumeric, options)); 100 'long tasks', longTaskNumeric, options);
101 values.addValue(longTaskValue);
102 var composition = tr.v.d.Composition.build(
103 values, 'long tasks ', slices, SLICE_NUMERIC_BUILDER,
104 tr.e.chrome.ChromeUserFriendlyCategoryDriver.fromEvent);
105 longTaskValue.diagnostics.add('category', composition);
93 } 106 }
94 107
95 tr.metrics.MetricRegistry.register(longTasksMetric, { 108 tr.metrics.MetricRegistry.register(longTasksMetric, {
96 supportsRangeOfInterest: true 109 supportsRangeOfInterest: true
97 }); 110 });
98 111
99 return { 112 return {
100 longTasksMetric: longTasksMetric, 113 longTasksMetric: longTasksMetric,
101 iterateLongTopLevelTasksOnThreadInRange: 114 iterateLongTopLevelTasksOnThreadInRange:
102 iterateLongTopLevelTasksOnThreadInRange, 115 iterateLongTopLevelTasksOnThreadInRange,
103 iterateRendererMainThreads: iterateRendererMainThreads, 116 iterateRendererMainThreads: iterateRendererMainThreads,
104 LONG_TASK_MS: LONG_TASK_MS, 117 LONG_TASK_MS: LONG_TASK_MS,
105 LONGEST_TASK_MS: LONGEST_TASK_MS 118 LONGEST_TASK_MS: LONGEST_TASK_MS
106 }; 119 };
107 }); 120 });
108 </script> 121 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698