| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 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/core/auditor.html"> | 8 <link rel="import" href="/tracing/core/auditor.html"> |
| 9 | 9 |
| 10 <script> | 10 <script> |
| 11 'use strict'; | 11 'use strict'; |
| 12 | 12 |
| 13 function filterDuplicateTimestamps(timestamps) { |
| 14 var dedupedTimestamps = []; |
| 15 var lastTs = 0; |
| 16 for (var ts of timestamps) { |
| 17 if (ts - lastTs >= 1) { |
| 18 dedupedTimestamps.push(ts); |
| 19 lastTs = ts; |
| 20 } |
| 21 } |
| 22 return dedupedTimestamps; |
| 23 } |
| 24 |
| 13 tr.exportTo('tr.e.audits', function() { | 25 tr.exportTo('tr.e.audits', function() { |
| 14 | 26 |
| 15 var VSYNC_COUNTER_PRECISIONS = { | 27 var VSYNC_COUNTER_PRECISIONS = { |
| 16 // Android. Some versions have VSYNC split out into VSYNC-app and VSYNC-sf. | 28 // Android. Some versions have VSYNC split out into VSYNC-app and VSYNC-sf. |
| 17 // Requires "gfx" systrace category to be enabled. | 29 // Requires "gfx" systrace category to be enabled. |
| 18 'android.VSYNC-app': 15, | 30 'android.VSYNC-app': 15, |
| 19 'android.VSYNC': 15 | 31 'android.VSYNC': 15 |
| 20 }; | 32 }; |
| 21 | 33 |
| 22 var VSYNC_SLICE_PRECISIONS = { | 34 var VSYNC_SLICE_PRECISIONS = { |
| 23 // Android. | 35 // Android. |
| 24 'RenderWidgetHostViewAndroid::OnVSync': 5, | 36 'RenderWidgetHostViewAndroid::OnVSync': 5, |
| 25 // Android. Very precise. Requires "gfx" systrace category to be enabled. | 37 // Android. Very precise. Requires "gfx" systrace category to be enabled. |
| 26 'VSYNC': 10, | 38 'VSYNC': 10, |
| 27 // Linux. Very precise. Requires "gpu" tracing category to be enabled. | 39 // Linux. Very precise. Requires "gpu" tracing category to be enabled. |
| 28 'vblank': 10, | 40 'vblank': 10, |
| 29 // Mac. Derived from a Mac callback (CVDisplayLinkSetOutputCallback). | 41 // Mac. Derived from a Mac callback (CVDisplayLinkSetOutputCallback). |
| 30 'DisplayLinkMac::GetVSyncParameters': 5 | 42 'DisplayLinkMac::GetVSyncParameters': 5 |
| 31 }; | 43 }; |
| 32 | 44 |
| 33 var BEGIN_FRAME_SLICE_PRECISION = { | 45 var BEGIN_FRAME_SLICE_PRECISION = { |
| 34 'Scheduler::BeginFrame': 10 | 46 'DisplayScheduler::BeginFrame': 10 |
| 35 }; | 47 }; |
| 36 | 48 |
| 37 /** | 49 /** |
| 38 * Auditor that analyzes the model and, if possible, adds data to it | 50 * Auditor that analyzes the model and, if possible, adds data to it |
| 39 * indicating when vertical sync events took place. | 51 * indicating when vertical sync events took place. |
| 40 * | 52 * |
| 41 * @constructor | 53 * @constructor |
| 42 * @extends {tr.c.Auditor} | 54 * @extends {tr.c.Auditor} |
| 43 */ | 55 */ |
| 44 function VSyncAuditor(model) { | 56 function VSyncAuditor(model) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // We need to check not only that we have a Scheduler::BeginFrame | 120 // We need to check not only that we have a Scheduler::BeginFrame |
| 109 // event, but also that we have one that has a frame time associated | 121 // event, but also that we have one that has a frame time associated |
| 110 // with it. Older versions of Scheduler::BeginFrame don't have one. | 122 // with it. Older versions of Scheduler::BeginFrame don't have one. |
| 111 else if (useInstead(slice.title, BEGIN_FRAME_SLICE_PRECISION) && | 123 else if (useInstead(slice.title, BEGIN_FRAME_SLICE_PRECISION) && |
| 112 slice.args.args && slice.args.args.frame_time_us) | 124 slice.args.args && slice.args.args.frame_time_us) |
| 113 times.push(slice.args.args.frame_time_us / 1000.0); | 125 times.push(slice.args.args.frame_time_us / 1000.0); |
| 114 } | 126 } |
| 115 } | 127 } |
| 116 } | 128 } |
| 117 times.sort(function(x, y) { return x - y; }); | 129 times.sort(function(x, y) { return x - y; }); |
| 118 return times; | 130 return filterDuplicateTimestamps(times); |
| 119 } | 131 } |
| 120 }; | 132 }; |
| 121 | 133 |
| 122 tr.c.Auditor.register(VSyncAuditor); | 134 tr.c.Auditor.register(VSyncAuditor); |
| 123 | 135 |
| 124 return { | 136 return { |
| 125 VSyncAuditor: VSyncAuditor | 137 VSyncAuditor: VSyncAuditor |
| 126 }; | 138 }; |
| 127 }); | 139 }); |
| 128 </script> | 140 </script> |
| OLD | NEW |