Index: tracing/tracing/metrics/vr/webvr_metric.html |
diff --git a/tracing/tracing/metrics/vr/webvr_metric.html b/tracing/tracing/metrics/vr/webvr_metric.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3674d377455a1a3de9cb10427b646320b4499da2 |
--- /dev/null |
+++ b/tracing/tracing/metrics/vr/webvr_metric.html |
@@ -0,0 +1,78 @@ |
+<!DOCTYPE html> |
+<!-- |
+Copyright 2017 The Chromium Authors. All rights reserved. |
+Use of this source code is governed by a BSD-style license that can be |
+found in the LICENSE file. |
+--> |
+ |
+<link rel="import" href="/tracing/metrics/metric_registry.html"> |
+<link rel="import" href="/tracing/value/histogram.html"> |
+ |
+<script> |
+'use strict'; |
+ |
+tr.exportTo('tr.metrics.vr', function() { |
+ function webvrMetric(histograms, model) { |
+ // Maps VR trace counters to histogram. |
+ const WEBVR_COUNTERS = new Map([ |
+ ['gpu.WebVR FPS', new Map([ |
+ ['name', 'webvr_fps'], |
+ ['unit', tr.b.Unit.byName.count_biggerIsBetter], |
+ ['options', new Map([ |
+ ['description', 'WebVR frame per second'], |
+ ['binBoundaries', |
+ tr.v.HistogramBinBoundaries.createLinear(20, 120, 25)] |
+ ])] |
+ ])], |
+ ['gpu.WebVR frame time (ms)', new Map([ |
+ ['name', 'webvr_frame_time'], |
+ ['unit', tr.b.Unit.byName.timeDurationInMs_smallerIsBetter], |
+ ['options', new Map([ |
+ ['description', 'WebVR frame time in ms'], |
+ ['binBoundaries', |
+ tr.v.HistogramBinBoundaries.createLinear(20, 120, 25)] |
+ ])] |
+ ])], |
+ ['gpu.WebVR pose prediction (ms)', new Map([ |
+ ['name', 'webvr_pose_prediction'], |
+ ['unit', tr.b.Unit.byName.timeDurationInMs_smallerIsBetter], |
+ ['options', new Map([ |
+ ['description', 'WebVR pose prediction in ms'], |
+ ['binBoundaries', |
+ tr.v.HistogramBinBoundaries.createLinear(20, 120, 25)] |
+ ])] |
+ ])] |
+ ]); |
+ |
+ for (const counter of model.getAllCounters()) { |
+ if (!(WEBVR_COUNTERS.has(counter.id))) continue; |
+ |
+ const nameToSamples = new Map(); |
+ for (const series of counter.series) { |
+ nameToSamples[series.name] = nameToSamples[series.name] || []; |
+ for (const sample of series.samples) { |
+ nameToSamples[series.name].push(sample.value); |
+ } |
+ } |
+ |
+ for (const [seriesName, samples] of Object.entries(nameToSamples)) { |
+ let name = WEBVR_COUNTERS.get(counter.id).get('name'); |
+ if (seriesName !== 'value') { |
+ name = name + '_' + seriesName; |
+ } |
+ |
+ histograms.createHistogram( |
+ name, WEBVR_COUNTERS.get(counter.id).get('unit'), samples, |
+ WEBVR_COUNTERS.get(counter.id).get('options') |
+ ); |
+ } |
+ } |
+ } |
+ |
+ tr.metrics.MetricRegistry.register(webvrMetric); |
+ |
+ return { |
+ webvrMetric, |
+ }; |
+}); |
+</script> |