OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/debug/frame_rate_counter.h" | 5 #include "cc/debug/frame_rate_counter.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "cc/trees/proxy.h" | 10 #include "cc/trees/proxy.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 // Walk backwards through the samples looking for a run of good frame | 105 // Walk backwards through the samples looking for a run of good frame |
106 // timings from which to compute the mean. | 106 // timings from which to compute the mean. |
107 // | 107 // |
108 // Slow frames occur just because the user is inactive, and should be | 108 // Slow frames occur just because the user is inactive, and should be |
109 // ignored. Fast frames are ignored if the scheduler is in single-thread | 109 // ignored. Fast frames are ignored if the scheduler is in single-thread |
110 // mode in order to represent the true frame rate in spite of the fact that | 110 // mode in order to represent the true frame rate in spite of the fact that |
111 // the first few swapbuffers happen instantly which skews the statistics | 111 // the first few swapbuffers happen instantly which skews the statistics |
112 // too much for short lived animations. | 112 // too much for short lived animations. |
113 // | 113 // |
114 // isBadFrameInterval encapsulates the frame too slow/frame too fast logic. | 114 // IsBadFrameInterval encapsulates the frame too slow/frame too fast logic. |
115 | 115 |
116 for (RingBufferType::Iterator it = --ring_buffer_.End(); | 116 for (RingBufferType::Iterator it = --ring_buffer_.End(); |
117 it && frame_times_total < 1.0; | 117 it && frame_times_total < 1.0; |
118 --it) { | 118 --it) { |
119 base::TimeDelta delta = RecentFrameInterval(it.index() + 1); | 119 base::TimeDelta delta = RecentFrameInterval(it.index() + 1); |
120 | 120 |
121 if (!IsBadFrameInterval(delta)) { | 121 if (!IsBadFrameInterval(delta)) { |
122 frame_count++; | 122 frame_count++; |
123 frame_times_total += delta.InSecondsF(); | 123 frame_times_total += delta.InSecondsF(); |
124 } else if (frame_count) { | 124 } else if (frame_count) { |
125 break; | 125 break; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 if (frame_count) { | 129 if (frame_count) { |
130 DCHECK_GT(frame_times_total, 0.0); | 130 DCHECK_GT(frame_times_total, 0.0); |
131 average_fps = frame_count / frame_times_total; | 131 average_fps = frame_count / frame_times_total; |
132 } | 132 } |
133 | 133 |
134 return average_fps; | 134 return average_fps; |
135 } | 135 } |
136 | 136 |
137 } // namespace cc | 137 } // namespace cc |
OLD | NEW |