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 = { | |
18 'gpu.WebVR FPS': | |
19 { 'name': 'webvr_fps', | |
benjhayden
2017/08/23 17:28:06
Please move the open brace to the previous line.
Lei Lei
2017/08/25 23:21:01
Done.
| |
20 'unit': tr.b.Unit.byName.count_biggerIsBetter, | |
21 'options': {'description': 'WebVR frame per second'} | |
22 }, | |
23 'gpu.WebVR frame time (ms)': | |
24 { 'name': 'webvr_frame_time', | |
25 'unit': tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, | |
26 'options': {'description': 'WebVR frame time in ms'} | |
27 }, | |
28 'gpu.WebVR pose prediction (ms)': | |
29 { 'name': 'webvr_pose_prediction', | |
30 'unit': tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, | |
31 'options': {'description': 'WebVR pose prediction in ms'} | |
32 } | |
33 }; | |
34 | |
35 for (const counter of model.getAllCounters()) { | |
36 if (!(counter.id in WEBVR_COUNTERS)) continue; | |
37 | |
38 const nameToSamples = {}; | |
benjhayden
2017/08/23 17:28:06
Please use an ES6 Map instead.
Lei Lei
2017/08/25 23:21:02
Done.
| |
39 for (const s of counter.series) { | |
benjhayden
2017/08/23 17:28:06
Please rename 's' to 'series' for clarity.
Lei Lei
2017/08/25 23:21:01
Done.
| |
40 nameToSamples[s.name] = nameToSamples[s.name] || []; | |
41 for (const sample of s.samples) { | |
42 nameToSamples[s.name].push(sample.value); | |
43 } | |
44 } | |
45 | |
46 for (const [serieName, samples] of Object.entries(nameToSamples)) { | |
benjhayden
2017/08/23 17:28:06
'serie' is not a word. 'Series' is both singular a
Lei Lei
2017/08/25 23:21:01
Done.
| |
47 let name = WEBVR_COUNTERS[counter.id].name; | |
48 if (serieName !== 'value') { | |
49 name = name + '_' + serieName; | |
50 } | |
51 histograms.createHistogram( | |
52 name, WEBVR_COUNTERS[counter.id].unit, samples, | |
53 WEBVR_COUNTERS[counter.id].options | |
54 ); | |
55 } | |
56 } | |
57 } | |
58 | |
59 tr.metrics.MetricRegistry.register(webvrMetric); | |
60 | |
61 return { | |
62 webvrMetric, | |
63 }; | |
64 }); | |
65 </script> | |
OLD | NEW |