Index: cc/trees/proxy_timing_history.cc |
diff --git a/cc/trees/proxy_timing_history.cc b/cc/trees/proxy_timing_history.cc |
index 6c45f71ed8649947e284e1de0e60225582b96f3e..9020ad51ef1d51e69efd4da7739eb7636e069298 100644 |
--- a/cc/trees/proxy_timing_history.cc |
+++ b/cc/trees/proxy_timing_history.cc |
@@ -4,6 +4,8 @@ |
#include "cc/trees/proxy_timing_history.h" |
+#include "base/metrics/histogram.h" |
+ |
const size_t kDurationHistorySize = 60; |
const double kCommitAndActivationDurationEstimationPercentile = 50.0; |
const double kDrawDurationEstimationPercentile = 100.0; |
@@ -11,10 +13,13 @@ const int kDrawDurationEstimatePaddingInMicroseconds = 0; |
namespace cc { |
-ProxyTimingHistory::ProxyTimingHistory() |
+ProxyTimingHistory::ProxyTimingHistory( |
+ RenderingStatsInstrumentation* rendering_stats_instrumentation) |
: draw_duration_history_(kDurationHistorySize), |
begin_main_frame_to_commit_duration_history_(kDurationHistorySize), |
- commit_to_activate_duration_history_(kDurationHistorySize) {} |
+ commit_to_activate_duration_history_(kDurationHistorySize), |
+ rendering_stats_instrumentation_(rendering_stats_instrumentation) { |
+} |
ProxyTimingHistory::~ProxyTimingHistory() {} |
@@ -43,24 +48,78 @@ void ProxyTimingHistory::DidBeginMainFrame() { |
void ProxyTimingHistory::DidCommit() { |
commit_complete_time_ = base::TimeTicks::HighResNow(); |
+ base::TimeDelta begin_main_frame_to_commit_duration = |
+ commit_complete_time_ - begin_main_frame_sent_time_; |
+ |
+ // Before adding the new data point to the timing history, see what we would |
+ // have predicted for this frame. This allows us to keep track of the accuracy |
+ // of our predictions. |
+ rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration( |
+ begin_main_frame_to_commit_duration, |
+ BeginMainFrameToCommitDurationEstimate()); |
+ |
begin_main_frame_to_commit_duration_history_.InsertSample( |
- commit_complete_time_ - begin_main_frame_sent_time_); |
+ begin_main_frame_to_commit_duration); |
} |
void ProxyTimingHistory::DidActivateSyncTree() { |
+ base::TimeDelta commit_to_activate_duration = |
+ base::TimeTicks::HighResNow() - commit_complete_time_; |
+ |
+ // Before adding the new data point to the timing history, see what we would |
+ // have predicted for this frame. This allows us to keep track of the accuracy |
+ // of our predictions. |
+ rendering_stats_instrumentation_->AddCommitToActivateDuration( |
+ commit_to_activate_duration, CommitToActivateDurationEstimate()); |
+ |
commit_to_activate_duration_history_.InsertSample( |
- base::TimeTicks::HighResNow() - commit_complete_time_); |
+ commit_to_activate_duration); |
} |
void ProxyTimingHistory::DidStartDrawing() { |
start_draw_time_ = base::TimeTicks::HighResNow(); |
} |
-base::TimeDelta ProxyTimingHistory::DidFinishDrawing() { |
+void ProxyTimingHistory::DidFinishDrawing() { |
base::TimeDelta draw_duration = |
base::TimeTicks::HighResNow() - start_draw_time_; |
+ |
+ // Before adding the new data point to the timing history, see what we would |
+ // have predicted for this frame. This allows us to keep track of the accuracy |
+ // of our predictions. |
+ base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); |
+ rendering_stats_instrumentation_->AddDrawDuration(draw_duration, |
+ draw_duration_estimate); |
+ |
+ AddDrawDurationUMA(draw_duration, draw_duration_estimate); |
+ |
draw_duration_history_.InsertSample(draw_duration); |
- return draw_duration; |
+} |
+ |
+void ProxyTimingHistory::AddDrawDurationUMA( |
+ base::TimeDelta draw_duration, |
+ base::TimeDelta draw_duration_estimate) { |
+ base::TimeDelta draw_duration_overestimate; |
+ base::TimeDelta draw_duration_underestimate; |
+ if (draw_duration > draw_duration_estimate) |
+ draw_duration_underestimate = draw_duration - draw_duration_estimate; |
+ else |
+ draw_duration_overestimate = draw_duration_estimate - draw_duration; |
+ UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration", |
+ draw_duration, |
+ base::TimeDelta::FromMilliseconds(1), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 50); |
+ UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate", |
+ draw_duration_underestimate, |
+ base::TimeDelta::FromMilliseconds(1), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 50); |
+ UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate", |
+ draw_duration_overestimate, |
+ base::TimeDelta::FromMilliseconds(1), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 50); |
} |
} // namespace cc |