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

Side by Side Diff: tracing/tracing/metrics/metric_map_function.html

Issue 2110683010: Allow benchmarks to specify running multiple metrics. (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: fix style 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>
charliea (OOO until 10-5) 2016/07/06 17:41:05 Can you write a test that uses multiple metrics?
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 === undefined)
charliea (OOO until 10-5) 2016/07/06 17:41:05 Maybe add a check for if metricNames.length === 0?
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(function(value) {
45 value.diagnostics.add(tr.v.ITERATION_INFO_DIAGNOSTIC_NAME, iteration); 47 value.diagnostics.add(tr.v.ITERATION_INFO_DIAGNOSTIC_NAME, iteration);
46 }); 48 });
47 } 49 }
48 50
49 result.addPair('values', values.valueDicts); 51 result.addPair('values', values.valueDicts);
50 } 52 }
51 53
52 pi.FunctionRegistry.register(metricMapFunction); 54 pi.FunctionRegistry.register(metricMapFunction);
53 55
54 return { 56 return {
55 metricMapFunction: metricMapFunction 57 metricMapFunction: metricMapFunction
56 }; 58 };
57 }); 59 });
58 </script> 60 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698