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/trees/proxy_timing_history.cc

Issue 363003002: Add duration estimation data to RenderingStats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ProxyTimingHistory adds samples. Created 6 years, 5 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/trees/proxy_timing_history.h"
6 6
7 #include "base/metrics/histogram.h"
8
7 const size_t kDurationHistorySize = 60; 9 const size_t kDurationHistorySize = 60;
8 const double kCommitAndActivationDurationEstimationPercentile = 50.0; 10 const double kCommitAndActivationDurationEstimationPercentile = 50.0;
9 const double kDrawDurationEstimationPercentile = 100.0; 11 const double kDrawDurationEstimationPercentile = 100.0;
10 const int kDrawDurationEstimatePaddingInMicroseconds = 0; 12 const int kDrawDurationEstimatePaddingInMicroseconds = 0;
11 13
12 namespace cc { 14 namespace cc {
13 15
14 ProxyTimingHistory::ProxyTimingHistory() 16 ProxyTimingHistory::ProxyTimingHistory(
17 RenderingStatsInstrumentation* rendering_stats_instrumentation)
15 : draw_duration_history_(kDurationHistorySize), 18 : draw_duration_history_(kDurationHistorySize),
16 begin_main_frame_to_commit_duration_history_(kDurationHistorySize), 19 begin_main_frame_to_commit_duration_history_(kDurationHistorySize),
17 commit_to_activate_duration_history_(kDurationHistorySize) {} 20 commit_to_activate_duration_history_(kDurationHistorySize),
21 rendering_stats_instrumentation_(rendering_stats_instrumentation) {
22 }
18 23
19 ProxyTimingHistory::~ProxyTimingHistory() {} 24 ProxyTimingHistory::~ProxyTimingHistory() {}
20 25
21 base::TimeDelta ProxyTimingHistory::DrawDurationEstimate() const { 26 base::TimeDelta ProxyTimingHistory::DrawDurationEstimate() const {
22 base::TimeDelta historical_estimate = 27 base::TimeDelta historical_estimate =
23 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); 28 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile);
24 base::TimeDelta padding = base::TimeDelta::FromMicroseconds( 29 base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
25 kDrawDurationEstimatePaddingInMicroseconds); 30 kDrawDurationEstimatePaddingInMicroseconds);
26 return historical_estimate + padding; 31 return historical_estimate + padding;
27 } 32 }
28 33
29 base::TimeDelta ProxyTimingHistory::BeginMainFrameToCommitDurationEstimate() 34 base::TimeDelta ProxyTimingHistory::BeginMainFrameToCommitDurationEstimate()
30 const { 35 const {
31 return begin_main_frame_to_commit_duration_history_.Percentile( 36 return begin_main_frame_to_commit_duration_history_.Percentile(
32 kCommitAndActivationDurationEstimationPercentile); 37 kCommitAndActivationDurationEstimationPercentile);
33 } 38 }
34 39
35 base::TimeDelta ProxyTimingHistory::CommitToActivateDurationEstimate() const { 40 base::TimeDelta ProxyTimingHistory::CommitToActivateDurationEstimate() const {
36 return commit_to_activate_duration_history_.Percentile( 41 return commit_to_activate_duration_history_.Percentile(
37 kCommitAndActivationDurationEstimationPercentile); 42 kCommitAndActivationDurationEstimationPercentile);
38 } 43 }
39 44
40 void ProxyTimingHistory::DidBeginMainFrame() { 45 void ProxyTimingHistory::DidBeginMainFrame() {
41 begin_main_frame_sent_time_ = base::TimeTicks::HighResNow(); 46 begin_main_frame_sent_time_ = base::TimeTicks::HighResNow();
42 } 47 }
43 48
44 void ProxyTimingHistory::DidCommit() { 49 void ProxyTimingHistory::DidCommit() {
45 commit_complete_time_ = base::TimeTicks::HighResNow(); 50 commit_complete_time_ = base::TimeTicks::HighResNow();
51 base::TimeDelta begin_main_frame_to_commit_duration =
52 commit_complete_time_ - begin_main_frame_sent_time_;
53
54 // 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
56 // of our predictions.
57 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration(
58 begin_main_frame_to_commit_duration,
59 BeginMainFrameToCommitDurationEstimate());
60
46 begin_main_frame_to_commit_duration_history_.InsertSample( 61 begin_main_frame_to_commit_duration_history_.InsertSample(
47 commit_complete_time_ - begin_main_frame_sent_time_); 62 begin_main_frame_to_commit_duration);
48 } 63 }
49 64
50 void ProxyTimingHistory::DidActivateSyncTree() { 65 void ProxyTimingHistory::DidActivateSyncTree() {
66 base::TimeDelta commit_to_activate_duration =
67 base::TimeTicks::HighResNow() - commit_complete_time_;
68
69 // 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
71 // of our predictions.
72 rendering_stats_instrumentation_->AddCommitToActivateDuration(
73 commit_to_activate_duration, CommitToActivateDurationEstimate());
74
51 commit_to_activate_duration_history_.InsertSample( 75 commit_to_activate_duration_history_.InsertSample(
52 base::TimeTicks::HighResNow() - commit_complete_time_); 76 commit_to_activate_duration);
53 } 77 }
54 78
55 void ProxyTimingHistory::DidStartDrawing() { 79 void ProxyTimingHistory::DidStartDrawing() {
56 start_draw_time_ = base::TimeTicks::HighResNow(); 80 start_draw_time_ = base::TimeTicks::HighResNow();
57 } 81 }
58 82
59 base::TimeDelta ProxyTimingHistory::DidFinishDrawing() { 83 void ProxyTimingHistory::DidFinishDrawing() {
60 base::TimeDelta draw_duration = 84 base::TimeDelta draw_duration =
61 base::TimeTicks::HighResNow() - start_draw_time_; 85 base::TimeTicks::HighResNow() - start_draw_time_;
86
87 // Before adding the new data point to the timing history, see what we would
88 // have predicted for this frame. This allows us to keep track of the accuracy
89 // of our predictions.
90 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
91 rendering_stats_instrumentation_->AddDrawDuration(draw_duration,
92 draw_duration_estimate);
93
94 AddDrawDurationUMA(draw_duration, draw_duration_estimate);
95
62 draw_duration_history_.InsertSample(draw_duration); 96 draw_duration_history_.InsertSample(draw_duration);
63 return draw_duration; 97 }
98
99 void ProxyTimingHistory::AddDrawDurationUMA(
100 base::TimeDelta draw_duration,
101 base::TimeDelta draw_duration_estimate) {
102 base::TimeDelta draw_duration_overestimate;
103 base::TimeDelta draw_duration_underestimate;
104 if (draw_duration > draw_duration_estimate)
105 draw_duration_underestimate = draw_duration - draw_duration_estimate;
106 else
107 draw_duration_overestimate = draw_duration_estimate - draw_duration;
108 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration",
109 draw_duration,
110 base::TimeDelta::FromMilliseconds(1),
111 base::TimeDelta::FromMilliseconds(100),
112 50);
113 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate",
114 draw_duration_underestimate,
115 base::TimeDelta::FromMilliseconds(1),
116 base::TimeDelta::FromMilliseconds(100),
117 50);
118 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate",
119 draw_duration_overestimate,
120 base::TimeDelta::FromMilliseconds(1),
121 base::TimeDelta::FromMilliseconds(100),
122 50);
64 } 123 }
65 124
66 } // namespace cc 125 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698