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

Side by Side Diff: tracing/tracing/metrics/metric_map_function.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
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="/perf_insights/mre/function_handle.html"> 8 <link rel="import" href="/perf_insights/mre/function_handle.html">
9 <link rel="import" href="/tracing/metrics/all_metrics.html"> 9 <link rel="import" href="/tracing/metrics/all_metrics.html">
10 <link rel="import" href="/tracing/metrics/metric_registry.html"> 10 <link rel="import" href="/tracing/metrics/metric_registry.html">
11 <link rel="import" href="/tracing/value/value_set.html"> 11 <link rel="import" href="/tracing/value/value_set.html">
12 12
13 <script> 13 <script>
14 'use strict'; 14 'use strict';
15 15
16 tr.exportTo('tr.metrics', function() { 16 tr.exportTo('tr.metrics', function() {
17 /** 17 /**
18 * @param {!pi.mre.MreResult} result 18 * @param {!pi.mre.MreResult} result
19 * @param {!tr.model.Model} model 19 * @param {!tr.model.Model} model
20 * @param {!Object} options 20 * @param {!Object} options
21 */ 21 */
22 function metricMapFunction(result, model, options) { 22 function metricMapFunction(result, model, options) {
23 if (options === undefined) 23 if (options === undefined)
24 throw new Error('Expected an options dict.'); 24 throw new Error('Expected an options dict.');
25 25
26 var metricName = options.metric; 26 var metricNames = options.metrics;
27 if (metricName === undefined) 27 if (!metricNames)
28 throw new Error('A metric name should be specified.'); 28 throw new Error('Metric names should be specified.');
29 29
30 var values = new tr.v.ValueSet(); 30 var values = new tr.v.ValueSet();
31 31
32 var metric = tr.metrics.MetricRegistry.findTypeInfoWithName(metricName); 32 for (var metricName of metricNames) {
33 if (metric === undefined) 33 var metric = tr.metrics.MetricRegistry.findTypeInfoWithName(metricName);
34 throw new Error('"' + metricName + '" is not a registered metric.'); 34 if (metric === undefined)
35 metric.constructor(values, model); 35 throw new Error('"' + metricName + '" is not a registered metric.');
36 metric.constructor(values, model);
37 }
36 38
37 for (var metadata of model.metadata) { 39 for (var metadata of model.metadata) {
38 if (!metadata.value || !metadata.value['iteration-info']) 40 if (!metadata.value || !metadata.value['iteration-info'])
39 continue; 41 continue;
40 var iteration = new tr.v.d.IterationInfo( 42 var iteration = new tr.v.d.IterationInfo(
41 metadata.value['iteration-info']); 43 metadata.value['iteration-info']);
42 // Values can be separated from their ValueSet and mixed into ValueSets 44 // Values can be separated from their ValueSet and mixed into ValueSets
43 // with Values from other iterations, so add IterationInfo to each Value. 45 // with Values from other iterations, so add IterationInfo to each Value.
44 values.map(function(value) { 46 values.map(v => iteration.addToValue(v));
45 value.diagnostics.add('iteration', iteration);
46 });
47 } 47 }
48 48
49 result.addPair('values', values.valueDicts); 49 result.addPair('values', values.valueDicts);
50 } 50 }
51 51
52 pi.FunctionRegistry.register(metricMapFunction); 52 pi.FunctionRegistry.register(metricMapFunction);
53 53
54 return { 54 return {
55 metricMapFunction: metricMapFunction 55 metricMapFunction: metricMapFunction
56 }; 56 };
57 }); 57 });
58 </script> 58 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/discover_unittest.py ('k') | tracing/tracing/metrics/metric_map_function_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698