Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: cc/scheduler/compositor_timing_history.cc

Issue 1184863004: cc: Move timing history to the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, add include Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/proxy_timing_history.h" 5 #include "cc/scheduler/compositor_timing_history.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "cc/debug/rendering_stats_instrumentation.h"
8 9
9 const size_t kDurationHistorySize = 60; 10 const size_t kDurationHistorySize = 60;
10 const double kCommitAndActivationDurationEstimationPercentile = 50.0; 11 const double kCommitAndActivationDurationEstimationPercentile = 50.0;
11 const double kDrawDurationEstimationPercentile = 100.0; 12 const double kDrawDurationEstimationPercentile = 100.0;
12 const int kDrawDurationEstimatePaddingInMicroseconds = 0; 13 const int kDrawDurationEstimatePaddingInMicroseconds = 0;
13 14
14 namespace cc { 15 namespace cc {
15 16
16 ProxyTimingHistory::ProxyTimingHistory( 17 CompositorTimingHistory::CompositorTimingHistory(
17 RenderingStatsInstrumentation* rendering_stats_instrumentation) 18 RenderingStatsInstrumentation* rendering_stats_instrumentation)
18 : draw_duration_history_(kDurationHistorySize), 19 : draw_duration_history_(kDurationHistorySize),
19 begin_main_frame_to_commit_duration_history_(kDurationHistorySize), 20 begin_main_frame_to_commit_duration_history_(kDurationHistorySize),
20 commit_to_activate_duration_history_(kDurationHistorySize), 21 commit_to_activate_duration_history_(kDurationHistorySize),
21 rendering_stats_instrumentation_(rendering_stats_instrumentation) { 22 rendering_stats_instrumentation_(rendering_stats_instrumentation) {
22 } 23 }
23 24
24 ProxyTimingHistory::~ProxyTimingHistory() {} 25 CompositorTimingHistory::~CompositorTimingHistory() {
26 }
25 27
26 base::TimeDelta ProxyTimingHistory::DrawDurationEstimate() const { 28 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const {
27 base::TimeDelta historical_estimate = 29 base::TimeDelta historical_estimate =
28 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); 30 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile);
29 base::TimeDelta padding = base::TimeDelta::FromMicroseconds( 31 base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
30 kDrawDurationEstimatePaddingInMicroseconds); 32 kDrawDurationEstimatePaddingInMicroseconds);
31 return historical_estimate + padding; 33 return historical_estimate + padding;
32 } 34 }
33 35
34 base::TimeDelta ProxyTimingHistory::BeginMainFrameToCommitDurationEstimate() 36 base::TimeDelta
35 const { 37 CompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const {
36 return begin_main_frame_to_commit_duration_history_.Percentile( 38 return begin_main_frame_to_commit_duration_history_.Percentile(
37 kCommitAndActivationDurationEstimationPercentile); 39 kCommitAndActivationDurationEstimationPercentile);
38 } 40 }
39 41
40 base::TimeDelta ProxyTimingHistory::CommitToActivateDurationEstimate() const { 42 base::TimeDelta CompositorTimingHistory::CommitToActivateDurationEstimate()
43 const {
41 return commit_to_activate_duration_history_.Percentile( 44 return commit_to_activate_duration_history_.Percentile(
42 kCommitAndActivationDurationEstimationPercentile); 45 kCommitAndActivationDurationEstimationPercentile);
43 } 46 }
44 47
45 void ProxyTimingHistory::DidBeginMainFrame() { 48 void CompositorTimingHistory::WillBeginMainFrame() {
46 begin_main_frame_sent_time_ = base::TimeTicks::Now(); 49 begin_main_frame_sent_time_ = base::TimeTicks::Now();
47 } 50 }
48 51
49 void ProxyTimingHistory::DidCommit() { 52 void CompositorTimingHistory::DidCommit() {
50 commit_complete_time_ = base::TimeTicks::Now(); 53 commit_complete_time_ = base::TimeTicks::Now();
51 base::TimeDelta begin_main_frame_to_commit_duration = 54 base::TimeDelta begin_main_frame_to_commit_duration =
52 commit_complete_time_ - begin_main_frame_sent_time_; 55 commit_complete_time_ - begin_main_frame_sent_time_;
53 56
54 // Before adding the new data point to the timing history, see what we would 57 // Before adding the new data point to the timing history, see what we would
55 // have predicted for this frame. This allows us to keep track of the accuracy 58 // have predicted for this frame. This allows us to keep track of the accuracy
56 // of our predictions. 59 // of our predictions.
57 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration( 60 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration(
58 begin_main_frame_to_commit_duration, 61 begin_main_frame_to_commit_duration,
59 BeginMainFrameToCommitDurationEstimate()); 62 BeginMainFrameToCommitDurationEstimate());
60 63
61 begin_main_frame_to_commit_duration_history_.InsertSample( 64 begin_main_frame_to_commit_duration_history_.InsertSample(
62 begin_main_frame_to_commit_duration); 65 begin_main_frame_to_commit_duration);
63 } 66 }
64 67
65 void ProxyTimingHistory::DidActivateSyncTree() { 68 void CompositorTimingHistory::DidActivateSyncTree() {
66 base::TimeDelta commit_to_activate_duration = 69 base::TimeDelta commit_to_activate_duration =
67 base::TimeTicks::Now() - commit_complete_time_; 70 base::TimeTicks::Now() - commit_complete_time_;
68 71
69 // Before adding the new data point to the timing history, see what we would 72 // Before adding the new data point to the timing history, see what we would
70 // have predicted for this frame. This allows us to keep track of the accuracy 73 // have predicted for this frame. This allows us to keep track of the accuracy
71 // of our predictions. 74 // of our predictions.
72 rendering_stats_instrumentation_->AddCommitToActivateDuration( 75 rendering_stats_instrumentation_->AddCommitToActivateDuration(
73 commit_to_activate_duration, CommitToActivateDurationEstimate()); 76 commit_to_activate_duration, CommitToActivateDurationEstimate());
74 77
75 commit_to_activate_duration_history_.InsertSample( 78 commit_to_activate_duration_history_.InsertSample(
76 commit_to_activate_duration); 79 commit_to_activate_duration);
77 } 80 }
78 81
79 void ProxyTimingHistory::DidStartDrawing() { 82 void CompositorTimingHistory::DidStartDrawing() {
80 start_draw_time_ = base::TimeTicks::Now(); 83 start_draw_time_ = base::TimeTicks::Now();
81 } 84 }
82 85
83 void ProxyTimingHistory::DidFinishDrawing() { 86 void CompositorTimingHistory::DidFinishDrawing() {
84 base::TimeDelta draw_duration = base::TimeTicks::Now() - start_draw_time_; 87 base::TimeDelta draw_duration = base::TimeTicks::Now() - start_draw_time_;
85 88
86 // Before adding the new data point to the timing history, see what we would 89 // Before adding the new data point to the timing history, see what we would
87 // have predicted for this frame. This allows us to keep track of the accuracy 90 // have predicted for this frame. This allows us to keep track of the accuracy
88 // of our predictions. 91 // of our predictions.
89 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 92 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
90 rendering_stats_instrumentation_->AddDrawDuration(draw_duration, 93 rendering_stats_instrumentation_->AddDrawDuration(draw_duration,
91 draw_duration_estimate); 94 draw_duration_estimate);
92 95
93 AddDrawDurationUMA(draw_duration, draw_duration_estimate); 96 AddDrawDurationUMA(draw_duration, draw_duration_estimate);
94 97
95 draw_duration_history_.InsertSample(draw_duration); 98 draw_duration_history_.InsertSample(draw_duration);
96 } 99 }
97 100
98 void ProxyTimingHistory::AddDrawDurationUMA( 101 void CompositorTimingHistory::AddDrawDurationUMA(
99 base::TimeDelta draw_duration, 102 base::TimeDelta draw_duration,
100 base::TimeDelta draw_duration_estimate) { 103 base::TimeDelta draw_duration_estimate) {
101 base::TimeDelta draw_duration_overestimate; 104 base::TimeDelta draw_duration_overestimate;
102 base::TimeDelta draw_duration_underestimate; 105 base::TimeDelta draw_duration_underestimate;
103 if (draw_duration > draw_duration_estimate) 106 if (draw_duration > draw_duration_estimate)
104 draw_duration_underestimate = draw_duration - draw_duration_estimate; 107 draw_duration_underestimate = draw_duration - draw_duration_estimate;
105 else 108 else
106 draw_duration_overestimate = draw_duration_estimate - draw_duration; 109 draw_duration_overestimate = draw_duration_estimate - draw_duration;
107 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration", 110 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration", draw_duration,
108 draw_duration,
109 base::TimeDelta::FromMilliseconds(1), 111 base::TimeDelta::FromMilliseconds(1),
110 base::TimeDelta::FromMilliseconds(100), 112 base::TimeDelta::FromMilliseconds(100), 50);
111 50);
112 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate", 113 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate",
113 draw_duration_underestimate, 114 draw_duration_underestimate,
114 base::TimeDelta::FromMilliseconds(1), 115 base::TimeDelta::FromMilliseconds(1),
115 base::TimeDelta::FromMilliseconds(100), 116 base::TimeDelta::FromMilliseconds(100), 50);
116 50);
117 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate", 117 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate",
118 draw_duration_overestimate, 118 draw_duration_overestimate,
119 base::TimeDelta::FromMilliseconds(1), 119 base::TimeDelta::FromMilliseconds(1),
120 base::TimeDelta::FromMilliseconds(100), 120 base::TimeDelta::FromMilliseconds(100), 50);
121 50);
122 } 121 }
123 122
124 } // namespace cc 123 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698