| OLD | NEW |
| 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 Loading... |
| 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> |
| OLD | NEW |