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
3 // found in the LICENSE file.
5 #include "cc/trees/proxy_timing_history.h"
7 const size_t kDurationHistorySize
= 60;
8 const double kCommitAndActivationDurationEstimationPercentile
= 50.0;
9 const double kDrawDurationEstimationPercentile
= 100.0;
10 const int kDrawDurationEstimatePaddingInMicroseconds
= 0;
14 ProxyTimingHistory::ProxyTimingHistory()
15 : draw_duration_history_(kDurationHistorySize
),
16 begin_main_frame_to_commit_duration_history_(kDurationHistorySize
),
17 commit_to_activate_duration_history_(kDurationHistorySize
) {}
19 ProxyTimingHistory::~ProxyTimingHistory() {}
21 base::TimeDelta
ProxyTimingHistory::DrawDurationEstimate() const {
22 base::TimeDelta historical_estimate
=
23 draw_duration_history_
.Percentile(kDrawDurationEstimationPercentile
);
24 base::TimeDelta padding
= base::TimeDelta::FromMicroseconds(
25 kDrawDurationEstimatePaddingInMicroseconds
);
26 return historical_estimate
+ padding
;
29 base::TimeDelta
ProxyTimingHistory::BeginMainFrameToCommitDurationEstimate()
31 return begin_main_frame_to_commit_duration_history_
.Percentile(
32 kCommitAndActivationDurationEstimationPercentile
);
35 base::TimeDelta
ProxyTimingHistory::CommitToActivateDurationEstimate() const {
36 return commit_to_activate_duration_history_
.Percentile(
37 kCommitAndActivationDurationEstimationPercentile
);
40 void ProxyTimingHistory::DidBeginMainFrame() {
41 begin_main_frame_sent_time_
= base::TimeTicks::HighResNow();
44 void ProxyTimingHistory::DidCommit() {
45 commit_complete_time_
= base::TimeTicks::HighResNow();
46 begin_main_frame_to_commit_duration_history_
.InsertSample(
47 commit_complete_time_
- begin_main_frame_sent_time_
);
50 void ProxyTimingHistory::DidActivateSyncTree() {
51 commit_to_activate_duration_history_
.InsertSample(
52 base::TimeTicks::HighResNow() - commit_complete_time_
);
55 void ProxyTimingHistory::DidStartDrawing() {
56 start_draw_time_
= base::TimeTicks::HighResNow();
59 base::TimeDelta
ProxyTimingHistory::DidFinishDrawing() {
60 base::TimeDelta draw_duration
=
61 base::TimeTicks::HighResNow() - start_draw_time_
;
62 draw_duration_history_
.InsertSample(draw_duration
);