1<!DOCTYPE html> 2<!-- 3Copyright 2016 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7<link rel="import" href="/perf_insights/function_handle.html"> 8<link rel="import" href="/tracing/metrics/all_metrics.html"> 9<link rel="import" href="/tracing/metrics/metric_registry.html"> 10<link rel="import" href="/tracing/metrics/value_list.html"> 11 12<script> 13'use strict'; 14 15tr.exportTo('tr.metrics', function() { 16 function metricMapFunction(result, model, options) { 17 if (options === undefined) 18 throw new Error('Expected an options dict.'); 19 var metricName = options.metric; 20 if (metricName === undefined) 21 throw new Error('A metric name should be specified.'); 22 var valueList = new tr.metrics.ValueList(); 23 var metric = tr.metrics.MetricRegistry.findTypeInfoWithName(metricName); 24 if (metric === undefined) 25 throw new Error('"' + metricName + '" is not a registered metric.'); 26 metric.constructor(valueList, model); 27 28 result.addPair('values', valueList.valueDicts); 29 } 30 31 pi.FunctionRegistry.register(metricMapFunction); 32 33 return { 34 metricMapFunction: metricMapFunction 35 }; 36}); 37</script> 38