OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2014 The Chromium Authors. All rights reserved. | 3 Copyright 2014 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/statistics.html"> | 8 <link rel="import" href="/tracing/base/math/statistics.html"> |
9 <link rel="import" href="/tracing/model/event_set.html"> | 9 <link rel="import" href="/tracing/model/event_set.html"> |
10 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> | 10 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> |
11 <link rel="import" href="/tracing/ui/base/dom_helpers.html"> | 11 <link rel="import" href="/tracing/ui/base/dom_helpers.html"> |
12 <link rel="import" href="/tracing/ui/base/line_chart.html"> | 12 <link rel="import" href="/tracing/ui/base/line_chart.html"> |
13 <link rel="import" href="/tracing/ui/side_panel/side_panel.html"> | 13 <link rel="import" href="/tracing/ui/side_panel/side_panel.html"> |
14 <link rel="import" href="/tracing/ui/side_panel/side_panel_registry.html"> | 14 <link rel="import" href="/tracing/ui/side_panel/side_panel_registry.html"> |
15 | 15 |
16 <dom-module id='tr-ui-e-s-input-latency-side-panel'> | 16 <dom-module id='tr-ui-e-s-input-latency-side-panel'> |
17 <template> | 17 <template> |
18 <style> | 18 <style> |
(...skipping 20 matching lines...) Expand all Loading... |
39 </dom-module> | 39 </dom-module> |
40 <script> | 40 <script> |
41 'use strict'; | 41 'use strict'; |
42 | 42 |
43 Polymer({ | 43 Polymer({ |
44 is: 'tr-ui-e-s-input-latency-side-panel', | 44 is: 'tr-ui-e-s-input-latency-side-panel', |
45 behaviors: [tr.ui.behaviors.SidePanel], | 45 behaviors: [tr.ui.behaviors.SidePanel], |
46 | 46 |
47 | 47 |
48 ready: function() { | 48 ready: function() { |
49 this.rangeOfInterest_ = new tr.b.Range(); | 49 this.rangeOfInterest_ = new tr.b.math.Range(); |
50 this.frametimeType_ = tr.model.helpers.IMPL_FRAMETIME_TYPE; | 50 this.frametimeType_ = tr.model.helpers.IMPL_FRAMETIME_TYPE; |
51 this.latencyChart_ = undefined; | 51 this.latencyChart_ = undefined; |
52 this.frametimeChart_ = undefined; | 52 this.frametimeChart_ = undefined; |
53 this.selectedProcessId_ = undefined; | 53 this.selectedProcessId_ = undefined; |
54 this.mouseDownIndex_ = undefined; | 54 this.mouseDownIndex_ = undefined; |
55 this.curMouseIndex_ = undefined; | 55 this.curMouseIndex_ = undefined; |
56 }, | 56 }, |
57 | 57 |
58 get model() { | 58 get model() { |
59 return this.model_; | 59 return this.model_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 setBrushedIndices: function(mouseDownIndex, curIndex) { | 104 setBrushedIndices: function(mouseDownIndex, curIndex) { |
105 this.mouseDownIndex_ = mouseDownIndex; | 105 this.mouseDownIndex_ = mouseDownIndex; |
106 this.curMouseIndex_ = curIndex; | 106 this.curMouseIndex_ = curIndex; |
107 this.updateBrushedRange_(); | 107 this.updateBrushedRange_(); |
108 }, | 108 }, |
109 | 109 |
110 updateBrushedRange_: function() { | 110 updateBrushedRange_: function() { |
111 if (this.latencyChart_ === undefined) | 111 if (this.latencyChart_ === undefined) |
112 return; | 112 return; |
113 | 113 |
114 var r = new tr.b.Range(); | 114 var r = new tr.b.math.Range(); |
115 if (this.mouseDownIndex_ === undefined) { | 115 if (this.mouseDownIndex_ === undefined) { |
116 this.latencyChart_.brushedRange = r; | 116 this.latencyChart_.brushedRange = r; |
117 return; | 117 return; |
118 } | 118 } |
119 r = this.latencyChart_.computeBrushRangeFromIndices( | 119 r = this.latencyChart_.computeBrushRangeFromIndices( |
120 this.mouseDownIndex_, this.curMouseIndex_); | 120 this.mouseDownIndex_, this.curMouseIndex_); |
121 this.latencyChart_.brushedRange = r; | 121 this.latencyChart_.brushedRange = r; |
122 | 122 |
123 // Based on the brushed range, update the selection of LatencyInfo in | 123 // Based on the brushed range, update the selection of LatencyInfo in |
124 // the timeline view by sending a selectionChange event. | 124 // the timeline view by sending a selectionChange event. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 this.selectedProcessId_ | 228 this.selectedProcessId_ |
229 ]; | 229 ]; |
230 else | 230 else |
231 chromeProcess = this.modelHelper_.browserHelper; | 231 chromeProcess = this.modelHelper_.browserHelper; |
232 | 232 |
233 var frameEvents = chromeProcess.getFrameEventsInRange( | 233 var frameEvents = chromeProcess.getFrameEventsInRange( |
234 this.frametimeType, rangeOfInterest); | 234 this.frametimeType, rangeOfInterest); |
235 | 235 |
236 var frametimeData = tr.model.helpers.getFrametimeDataFromEvents( | 236 var frametimeData = tr.model.helpers.getFrametimeDataFromEvents( |
237 frameEvents); | 237 frameEvents); |
238 var averageFrametime = tr.b.Statistics.mean(frametimeData, function(d) { | 238 var averageFrametime = tr.b.math.Statistics.mean(frametimeData, d => |
239 return d.frametime; | 239 d.frametime |
240 }); | 240 ); |
241 | 241 |
242 var latencyEvents = this.modelHelper_.browserHelper. | 242 var latencyEvents = this.modelHelper_.browserHelper. |
243 getLatencyEventsInRange( | 243 getLatencyEventsInRange( |
244 rangeOfInterest); | 244 rangeOfInterest); |
245 | 245 |
246 var latencyData = []; | 246 var latencyData = []; |
247 latencyEvents.forEach(function(event) { | 247 latencyEvents.forEach(function(event) { |
248 if (event.inputLatency === undefined) | 248 if (event.inputLatency === undefined) |
249 return; | 249 return; |
250 latencyData.push({ | 250 latencyData.push({ |
251 x: event.start, | 251 x: event.start, |
252 latency: event.inputLatency / 1000 | 252 latency: event.inputLatency / 1000 |
253 }); | 253 }); |
254 }); | 254 }); |
255 | 255 |
256 var averageLatency = tr.b.Statistics.mean(latencyData, function(d) { | 256 var averageLatency = tr.b.math.Statistics.mean(latencyData, function(d) { |
257 return d.latency; | 257 return d.latency; |
258 }); | 258 }); |
259 | 259 |
260 // Create summary. | 260 // Create summary. |
261 var latencySummaryText = document.createElement('div'); | 261 var latencySummaryText = document.createElement('div'); |
262 Polymer.dom(latencySummaryText).appendChild(tr.ui.b.createSpan({ | 262 Polymer.dom(latencySummaryText).appendChild(tr.ui.b.createSpan({ |
263 textContent: 'Average Latency ' + averageLatency + ' ms', | 263 textContent: 'Average Latency ' + averageLatency + ' ms', |
264 bold: true})); | 264 bold: true})); |
265 Polymer.dom(resultArea).appendChild(latencySummaryText); | 265 Polymer.dom(resultArea).appendChild(latencySummaryText); |
266 | 266 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 get textLabel() { | 324 get textLabel() { |
325 return 'Input Latency'; | 325 return 'Input Latency'; |
326 } | 326 } |
327 }); | 327 }); |
328 | 328 |
329 tr.ui.side_panel.SidePanelRegistry.register(function() { | 329 tr.ui.side_panel.SidePanelRegistry.register(function() { |
330 return document.createElement('tr-ui-e-s-input-latency-side-panel'); | 330 return document.createElement('tr-ui-e-s-input-latency-side-panel'); |
331 }); | 331 }); |
332 </script> | 332 </script> |
OLD | NEW |