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

Side by Side Diff: tracing/tracing/value/diagnostics/composition.html

Issue 2293533002: Refactor NumericBuilder to HistogramBinBoundaries. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 years, 3 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" href="/tracing/value/diagnostics/related_value_map.html"> 8 <link rel="import" href="/tracing/value/diagnostics/related_value_map.html">
9 9
10 <script> 10 <script>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 * Build a Composition and its NumericValues from |events|. Group events 76 * Build a Composition and its NumericValues from |events|. Group events
77 * using |categoryForEvent|. Add the NumericValues to |values|. 77 * using |categoryForEvent|. Add the NumericValues to |values|.
78 * NumericValues' names are prefixed with |namePrefix|. Numerics are built by 78 * NumericValues' names are prefixed with |namePrefix|. Numerics are built by
79 * |numericBuilder|. The numeric sample for each Event is derived from 79 * |numericBuilder|. The numeric sample for each Event is derived from
80 * |opt_sampleForEvent|, which defaults to event.cpuSelfTime. The caller must 80 * |opt_sampleForEvent|, which defaults to event.cpuSelfTime. The caller must
81 * add the result Composition to their Value's diagnostics. 81 * add the result Composition to their Value's diagnostics.
82 * 82 *
83 * @param {!tr.v.ValueSet} values 83 * @param {!tr.v.ValueSet} values
84 * @param {string} namePrefix 84 * @param {string} namePrefix
85 * @param {!tr.model.EventSet} events 85 * @param {!tr.model.EventSet} events
86 * @param {!tr.v.NumericBuilder} numericBuilder
87 * @param {!function(!tr.model.Event):string} categoryForEvent 86 * @param {!function(!tr.model.Event):string} categoryForEvent
87 * @param {!tr.v.Unit} unit
88 * @param {!function(!tr.model.Event):number=} opt_sampleForEvent 88 * @param {!function(!tr.model.Event):number=} opt_sampleForEvent
89 * @param {!tr.v.HistogramBinBoundaries=} opt_binBoundaries
89 * @param {*=} opt_this 90 * @param {*=} opt_this
90 * @return {!Composition} 91 * @return {!Composition}
91 */ 92 */
92 static buildFromEvents(values, namePrefix, events, numericBuilder, 93 static buildFromEvents(values, namePrefix, events, categoryForEvent, unit,
93 categoryForEvent, opt_sampleForEvent, opt_this) { 94 opt_sampleForEvent, opt_binBoundaries, opt_this) {
94 var sampleForEvent = opt_sampleForEvent || ((event) => event.cpuSelfTime); 95 var sampleForEvent = opt_sampleForEvent || ((event) => event.cpuSelfTime);
95 96
96 var composition = new Composition(); 97 var composition = new Composition();
97 for (var event of events) { 98 for (var event of events) {
98 var sample = sampleForEvent.call(opt_this, event); 99 var sample = sampleForEvent.call(opt_this, event);
99 if (sample === undefined) 100 if (sample === undefined)
100 continue; 101 continue;
101 102
102 var eventCategory = categoryForEvent.call(opt_this, event); 103 var eventCategory = categoryForEvent.call(opt_this, event);
103 var value = composition.get(eventCategory); 104 var value = composition.get(eventCategory);
104 if (value === undefined) { 105 if (value === undefined) {
105 value = new tr.v.NumericValue( 106 value = new tr.v.NumericValue(namePrefix + eventCategory,
106 namePrefix + eventCategory, numericBuilder.build()); 107 new tr.v.Histogram(unit, opt_binBoundaries));
107 values.addValue(value); 108 values.addValue(value);
108 composition.set(eventCategory, value); 109 composition.set(eventCategory, value);
109 } 110 }
110 111
111 value.numeric.add(sample, tr.v.d.DiagnosticMap.fromObject( 112 value.numeric.add(sample, tr.v.d.DiagnosticMap.fromObject(
112 {relatedEvents: new tr.v.d.RelatedEventSet([event])})); 113 {relatedEvents: new tr.v.d.RelatedEventSet([event])}));
113 } 114 }
114 return composition; 115 return composition;
115 } 116 }
116 }; 117 };
117 118
118 tr.v.d.Diagnostic.register(Composition, { 119 tr.v.d.Diagnostic.register(Composition, {
119 elementName: 'tr-v-ui-composition-span' 120 elementName: 'tr-v-ui-composition-span'
120 }); 121 });
121 122
122 return { 123 return {
123 COLOR_SCHEME_CHROME_USER_FRIENDLY_CATEGORY_DRIVER: 124 COLOR_SCHEME_CHROME_USER_FRIENDLY_CATEGORY_DRIVER:
124 COLOR_SCHEME_CHROME_USER_FRIENDLY_CATEGORY_DRIVER, 125 COLOR_SCHEME_CHROME_USER_FRIENDLY_CATEGORY_DRIVER,
125 Composition: Composition 126 Composition: Composition
126 }; 127 };
127 }); 128 });
128 </script> 129 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/v8/gc_metric.html ('k') | tracing/tracing/value/diagnostics/composition_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698