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

Side by Side Diff: cc/CCFrameRateCounter.h

Issue 11028021: cc: Improve frame/commit accounting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use uint64_t and rename variables to *Count Created 8 years, 2 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 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 #ifndef CCFrameRateCounter_h 5 #ifndef CCFrameRateCounter_h
6 #define CCFrameRateCounter_h 6 #define CCFrameRateCounter_h
7 7
8 #if USE(ACCELERATED_COMPOSITING) 8 #if USE(ACCELERATED_COMPOSITING)
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include <wtf/PassOwnPtr.h> 11 #include <wtf/PassOwnPtr.h>
12 12
13 namespace cc { 13 namespace cc {
14 14
15 // This class maintains a history of timestamps, and provides functionality to 15 // This class maintains a history of timestamps, and provides functionality to
16 // intelligently compute average frames per second (and standard deviation). 16 // intelligently compute average frames per second (and standard deviation).
17 class CCFrameRateCounter { 17 class CCFrameRateCounter {
18 public: 18 public:
19 static PassOwnPtr<CCFrameRateCounter> create() 19 static PassOwnPtr<CCFrameRateCounter> create()
20 { 20 {
21 return adoptPtr(new CCFrameRateCounter()); 21 return adoptPtr(new CCFrameRateCounter());
22 } 22 }
23 23
24 void markBeginningOfFrame(double timestamp); 24 void markBeginningOfFrame(double timestamp);
25 void markEndOfFrame(); 25 void markEndOfFrame();
26 int currentFrameNumber() const { return m_currentFrameNumber; } 26 uint64_t currentFrameNumber() const { return m_currentFrameNumber; }
27 void getAverageFPSAndStandardDeviation(double& averageFPS, double& standardD eviation) const; 27 void getAverageFPSAndStandardDeviation(double& averageFPS, double& standardD eviation) const;
28 int timeStampHistorySize() const { return kTimeStampHistorySize; } 28 int timeStampHistorySize() const { return kTimeStampHistorySize; }
29 29
30 // n = 0 returns the oldest frame retained in the history, 30 // n = 0 returns the oldest frame retained in the history,
31 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr ame. 31 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr ame.
32 double timeStampOfRecentFrame(int /* n */); 32 double timeStampOfRecentFrame(int /* n */);
33 33
34 // This is a heuristic that can be used to ignore frames in a reasonable way . Returns 34 // This is a heuristic that can be used to ignore frames in a reasonable way . Returns
35 // true if the given frame interval is too fast or too slow, based on consta nt thresholds. 35 // true if the given frame interval is too fast or too slow, based on consta nt thresholds.
36 bool isBadFrameInterval(double intervalBetweenConsecutiveFrames) const; 36 bool isBadFrameInterval(double intervalBetweenConsecutiveFrames) const;
37 37
38 int droppedFrameCount() const { return m_droppedFrameCount; }
39
40 private: 38 private:
41 CCFrameRateCounter(); 39 CCFrameRateCounter();
42 40
43 double frameInterval(int frameNumber) const; 41 double frameInterval(int frameNumber) const;
44 int frameIndex(int frameNumber) const; 42 int frameIndex(int frameNumber) const;
45 bool isBadFrame(int frameNumber) const; 43 bool isBadFrame(int frameNumber) const;
46 44
47 // Two thresholds (measured in seconds) that describe what is considered to be a "no-op frame" that should not be counted. 45 // Two thresholds (measured in seconds) that describe what is considered to be a "no-op frame" that should not be counted.
48 // - if the frame is too fast, then given our compositor implementation, the frame probably was a no-op and did not draw. 46 // - if the frame is too fast, then given our compositor implementation, the frame probably was a no-op and did not draw.
49 // - if the frame is too slow, then there is probably not animating content, so we should not pollute the average. 47 // - if the frame is too slow, then there is probably not animating content, so we should not pollute the average.
50 static const double kFrameTooFast; 48 static const double kFrameTooFast;
51 static const double kFrameTooSlow; 49 static const double kFrameTooSlow;
52 50
53 // If a frame takes longer than this threshold (measured in seconds) then we 51 // If a frame takes longer than this threshold (measured in seconds) then we
54 // (naively) assume that it missed a screen refresh; that is, we dropped a f rame. 52 // (naively) assume that it missed a screen refresh; that is, we dropped a f rame.
55 // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/ 138642. 53 // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/ 138642.
56 static const double kDroppedFrameTime; 54 static const double kDroppedFrameTime;
57 55
58 static const int kTimeStampHistorySize = 120; 56 static const int kTimeStampHistorySize = 120;
59 57
60 int m_currentFrameNumber; 58 uint64_t m_currentFrameNumber;
61 double m_timeStampHistory[kTimeStampHistorySize]; 59 double m_timeStampHistory[kTimeStampHistorySize];
62 60
63 int m_droppedFrameCount;
64
65 DISALLOW_COPY_AND_ASSIGN(CCFrameRateCounter); 61 DISALLOW_COPY_AND_ASSIGN(CCFrameRateCounter);
66 }; 62 };
67 63
68 } // namespace cc 64 } // namespace cc
69 65
70 #endif // USE(ACCELERATED_COMPOSITING) 66 #endif // USE(ACCELERATED_COMPOSITING)
71 67
72 #endif 68 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698