Chromium Code Reviews| Index: cc/frame_rate_counter.cc |
| diff --git a/cc/frame_rate_counter.cc b/cc/frame_rate_counter.cc |
| index d84b74436a08dad69bac4df8e5c8f1e1d01c2c23..4b1153e877780f817b204d181a25d86255180074 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; |
|
egraether
2012/11/12 23:44:06
Reduced the kFrameTooSlow value so that only time
nduca
2012/11/13 00:51:46
How about .25 second? I'm thinking about pauses as
|
| 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 |
|
egraether
2012/11/12 23:44:06
Method returns now the average only. Standard devi
|
| { |
| int frameNumber = m_currentFrameNumber - 1; |
| int frameCount = 0; |
| - double fpsVarianceNumerator = 0; |
| - |
| - averageFPS = 0; |
| - standardDeviation = 0; |
| + double frameDeltas = 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 && frameDeltas < 1.0) { |
|
egraether
2012/11/12 23:44:06
I added a check for a maximum time of 1 second, so
|
| base::TimeDelta delta = frameInterval(frameNumber); |
| if (!isBadFrameInterval(delta)) { |
| frameCount++; |
| - double x = 1.0 / delta.InSecondsF(); |
|
egraether
2012/11/12 23:44:06
This average calculation is wrong, because x is al
|
| - double deltaFromAverage = x - averageFPS; |
| - // Change with caution - numerics. http://en.wikipedia.org/wiki/Standard_deviation |
| - averageFPS += deltaFromAverage / frameCount; |
| - fpsVarianceNumerator += deltaFromAverage * (x - averageFPS); |
|
egraether
2012/11/12 23:44:06
The standard deviation calculation was thereon wro
|
| + frameDeltas += 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 / frameDeltas; |
|
egraether
2012/11/12 23:44:06
The average needs to be calculated by total count
nduca
2012/11/13 00:51:46
frameDeltas is an oddly named var. Can you make be
|
| + |
| + return averageFPS; |
| } |
| base::TimeTicks FrameRateCounter::timeStampOfRecentFrame(int n) const |