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

Unified Diff: cc/frame_rate_counter.cc

Issue 11369200: improving UI of FPS counter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 167687 Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/frame_rate_counter.h ('k') | cc/heads_up_display_layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/frame_rate_counter.cc
diff --git a/cc/frame_rate_counter.cc b/cc/frame_rate_counter.cc
index d84b74436a08dad69bac4df8e5c8f1e1d01c2c23..c37956f78c8d06f0e2c1a68a611c9bce17ecf215 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
« no previous file with comments | « cc/frame_rate_counter.h ('k') | cc/heads_up_display_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698