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/core/test_utils.html"> |
| 9 <link rel="import" href="/tracing/metrics/vr/webvr_metric.html"> |
| 10 <link rel="import" href="/tracing/model/counter.html"> |
| 11 <link rel="import" href="/tracing/model/model.html"> |
| 12 <link rel="import" href="/tracing/value/histogram_set.html"> |
| 13 |
| 14 <script> |
| 15 'use strict'; |
| 16 |
| 17 tr.b.unittest.testSuite(function() { |
| 18 function createModel() { |
| 19 const model = tr.c.TestUtils.newModel( |
| 20 function(model) { |
| 21 const process = model.getOrCreateProcess(1); |
| 22 const fpsCounter = process.getOrCreateCounter('gpu', 'WebVR FPS'); |
| 23 const fpsSeries = new tr.model.CounterSeries('value', 0); |
| 24 fpsSeries.addCounterSample(1, 59); |
| 25 fpsSeries.addCounterSample(3, 60); |
| 26 fpsCounter.addSeries(fpsSeries); |
| 27 |
| 28 const frameTimeCounter = process.getOrCreateCounter( |
| 29 'gpu', 'WebVR frame time (ms)'); |
| 30 const renderingSeries = new tr.model.CounterSeries('rendering', 0); |
| 31 renderingSeries.addCounterSample(1, 3); |
| 32 renderingSeries.addCounterSample(2, 4); |
| 33 frameTimeCounter.addSeries(renderingSeries); |
| 34 const javascriptSeries = new tr.model.CounterSeries('javascript', 0); |
| 35 javascriptSeries.addCounterSample(1, 5); |
| 36 javascriptSeries.addCounterSample(2, 6); |
| 37 frameTimeCounter.addSeries(javascriptSeries); |
| 38 }); |
| 39 return model; |
| 40 } |
| 41 |
| 42 test('webvrMetric', function() { |
| 43 const histograms = new tr.v.HistogramSet(); |
| 44 const model = createModel(); |
| 45 tr.metrics.vr.webvrMetric(histograms, model); |
| 46 |
| 47 const fpsValue = histograms.getHistogramNamed('webvr_fps'); |
| 48 assert.strictEqual(fpsValue.max, 60); |
| 49 assert.strictEqual(fpsValue.min, 59); |
| 50 assert.strictEqual(fpsValue.average, 59.5); |
| 51 |
| 52 const renderingValue = histograms.getHistogramNamed( |
| 53 'webvr_frame_time_rendering'); |
| 54 assert.strictEqual(renderingValue.max, 4); |
| 55 assert.strictEqual(renderingValue.min, 3); |
| 56 assert.strictEqual(renderingValue.average, 3.5); |
| 57 |
| 58 const javascriptValue = histograms.getHistogramNamed( |
| 59 'webvr_frame_time_javascript'); |
| 60 assert.strictEqual(javascriptValue.max, 6); |
| 61 assert.strictEqual(javascriptValue.min, 5); |
| 62 assert.strictEqual(javascriptValue.average, 5.5); |
| 63 }); |
| 64 }); |
| 65 </script> |
OLD | NEW |