diff options
author | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 23:34:55 +0000 |
---|---|---|
committer | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 23:34:55 +0000 |
commit | 2065bce60e9fefa0a0325c6467e8c6b543f1a294 (patch) | |
tree | f5c0f1a546e661f15942d232afcd1571856ef675 /cc/frame_rate_counter.cc | |
parent | f89f563c49877af2093975735c2abf6a56d1a1e5 (diff) | |
download | chromium_src-2065bce60e9fefa0a0325c6467e8c6b543f1a294.zip chromium_src-2065bce60e9fefa0a0325c6467e8c6b543f1a294.tar.gz chromium_src-2065bce60e9fefa0a0325c6467e8c6b543f1a294.tar.bz2 |
improving UI of FPS counter
The FPS counter shows the frame rate based on a time-stamp history and is located in the compositor's HUDLayer.
This change includes:
- moving to top right corner
- plotting the graph's X-axis based on time between frames
- measuring min/max value instead of standard deviation
- showing histogram of time spent in each value
- scaling to the max value in case of very high fps (disabled vsync)
comparison images:
https://docs.google.com/folder/d/0B8Y78t3tjy1XTC1OYzUySFgwODQ/edit
Review URL: https://chromiumcodereview.appspot.com/11369200
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/frame_rate_counter.cc')
-rw-r--r-- | cc/frame_rate_counter.cc | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/cc/frame_rate_counter.cc b/cc/frame_rate_counter.cc index d84b744..c37956f 100644 --- a/cc/frame_rate_counter.cc +++ b/cc/frame_rate_counter.cc @@ -12,7 +12,7 @@ namespace cc { const double FrameRateCounter::kFrameTooFast = 1.0 / 70.0; // measured in seconds -const double FrameRateCounter::kFrameTooSlow = 1.0 / 12.0; +const double FrameRateCounter::kFrameTooSlow = 1.0 / 4.0; const double FrameRateCounter::kDroppedFrameTime = 1.0 / 50.0; // safeMod works on -1, returning m-1 in that case. @@ -81,17 +81,15 @@ bool FrameRateCounter::isBadFrame(int frameNumber) const return isBadFrameInterval(frameInterval(frameNumber)); } -void FrameRateCounter::getAverageFPSAndStandardDeviation(double& averageFPS, double& standardDeviation) const +double FrameRateCounter::getAverageFPS() const { int frameNumber = m_currentFrameNumber - 1; int frameCount = 0; - double fpsVarianceNumerator = 0; - - averageFPS = 0; - standardDeviation = 0; + double frameTimesTotal = 0; + double averageFPS = 0; // Walk backwards through the samples looking for a run of good frame - // timings from which to compute the mean and standard deviation. + // timings from which to compute the mean. // // Slow frames occur just because the user is inactive, and should be // ignored. Fast frames are ignored if the scheduler is in single-thread @@ -99,27 +97,24 @@ void FrameRateCounter::getAverageFPSAndStandardDeviation(double& averageFPS, dou // the first few swapbuffers happen instantly which skews the statistics // too much for short lived animations. // - // isBadFrame encapsulates the frame too slow/frame too fast logic. + // isBadFrameInterval encapsulates the frame too slow/frame too fast logic. - // Go through all available historical data. - while (frameIndex(frameNumber) != frameIndex(m_currentFrameNumber) && frameNumber >= 0) { + while (frameIndex(frameNumber) != frameIndex(m_currentFrameNumber) && frameNumber >= 0 && frameTimesTotal < 1.0) { base::TimeDelta delta = frameInterval(frameNumber); if (!isBadFrameInterval(delta)) { frameCount++; - double x = 1.0 / delta.InSecondsF(); - double deltaFromAverage = x - averageFPS; - // Change with caution - numerics. http://en.wikipedia.org/wiki/Standard_deviation - averageFPS += deltaFromAverage / frameCount; - fpsVarianceNumerator += deltaFromAverage * (x - averageFPS); + frameTimesTotal += delta.InSecondsF(); } else if (frameCount) - // We've gathered a run of good samples, so stop. break; + frameNumber--; } if (frameCount) - standardDeviation = sqrt(fpsVarianceNumerator / frameCount); + averageFPS = frameCount / frameTimesTotal; + + return averageFPS; } base::TimeTicks FrameRateCounter::timeStampOfRecentFrame(int n) const |