OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Copyright 2017 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. |
| 6 --> |
| 7 |
| 8 <link rel="import" href="/tracing/metrics/metric_registry.html"> |
| 9 <link rel="import" href="/tracing/value/histogram.html"> |
| 10 |
| 11 <script> |
| 12 'use strict'; |
| 13 |
| 14 tr.exportTo('tr.metrics.vr', function() { |
| 15 function webvrMetric(histograms, model) { |
| 16 // Maps VR trace counters to histogram. |
| 17 const WEBVR_COUNTERS = new Map([ |
| 18 ['gpu.WebVR FPS', new Map([ |
| 19 ['name', 'webvr_fps'], |
| 20 ['unit', tr.b.Unit.byName.count_biggerIsBetter], |
| 21 ['options', new Map([ |
| 22 ['description', 'WebVR frame per second'], |
| 23 ['binBoundaries', |
| 24 tr.v.HistogramBinBoundaries.createLinear(20, 120, 25)] |
| 25 ])] |
| 26 ])], |
| 27 ['gpu.WebVR frame time (ms)', new Map([ |
| 28 ['name', 'webvr_frame_time'], |
| 29 ['unit', tr.b.Unit.byName.timeDurationInMs_smallerIsBetter], |
| 30 ['options', new Map([ |
| 31 ['description', 'WebVR frame time in ms'], |
| 32 ['binBoundaries', |
| 33 tr.v.HistogramBinBoundaries.createLinear(20, 120, 25)] |
| 34 ])] |
| 35 ])], |
| 36 ['gpu.WebVR pose prediction (ms)', new Map([ |
| 37 ['name', 'webvr_pose_prediction'], |
| 38 ['unit', tr.b.Unit.byName.timeDurationInMs_smallerIsBetter], |
| 39 ['options', new Map([ |
| 40 ['description', 'WebVR pose prediction in ms'], |
| 41 ['binBoundaries', |
| 42 tr.v.HistogramBinBoundaries.createLinear(20, 120, 25)] |
| 43 ])] |
| 44 ])] |
| 45 ]); |
| 46 |
| 47 for (const counter of model.getAllCounters()) { |
| 48 if (!(WEBVR_COUNTERS.has(counter.id))) continue; |
| 49 |
| 50 const nameToSamples = new Map(); |
| 51 for (const series of counter.series) { |
| 52 nameToSamples[series.name] = nameToSamples[series.name] || []; |
| 53 for (const sample of series.samples) { |
| 54 nameToSamples[series.name].push(sample.value); |
| 55 } |
| 56 } |
| 57 |
| 58 for (const [seriesName, samples] of Object.entries(nameToSamples)) { |
| 59 let name = WEBVR_COUNTERS.get(counter.id).get('name'); |
| 60 if (seriesName !== 'value') { |
| 61 name = name + '_' + seriesName; |
| 62 } |
| 63 |
| 64 histograms.createHistogram( |
| 65 name, WEBVR_COUNTERS.get(counter.id).get('unit'), samples, |
| 66 WEBVR_COUNTERS.get(counter.id).get('options') |
| 67 ); |
| 68 } |
| 69 } |
| 70 } |
| 71 |
| 72 tr.metrics.MetricRegistry.register(webvrMetric); |
| 73 |
| 74 return { |
| 75 webvrMetric, |
| 76 }; |
| 77 }); |
| 78 </script> |
OLD | NEW |