Bug 1029559 - The framerate front should have a means of clamping the generated values (relanded), r=pbrosset

This commit is contained in:
Victor Porof 2014-06-25 13:32:07 -04:00
parent bd62408979
commit a2f15d81b9
2 changed files with 6 additions and 4 deletions

View File

@ -121,11 +121,13 @@ let FramerateFront = exports.FramerateFront = protocol.FrontClass(FramerateActor
* the elapsed time on each refresh driver tick.
* @param number interval
* The maximum amount of time to wait between calculations.
* @param number clamp
* The maximum allowed framerate value.
* @return array
* A collection of { delta, value } objects representing the
* framerate value at every delta time.
*/
plotFPS: function(ticks, interval = 100) {
plotFPS: function(ticks, interval = 100, clamp = 60) {
let timeline = [];
let totalTicks = ticks.length;
@ -149,7 +151,7 @@ let FramerateFront = exports.FramerateFront = protocol.FrontClass(FramerateActor
continue;
}
let framerate = 1000 / (elapsedTime / frameCount);
let framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
timeline.push({ delta: prevTime, value: framerate });
timeline.push({ delta: currTime, value: framerate });

View File

@ -86,10 +86,10 @@ window.onload = function() {
is(currFramerateStart, currFramerateEnd,
"The start and end framerate values should be equal.");
isnot(currFramerateStart, prevFramerateValue,
"There should be different framerate values for each bucket.");
is(typeof currFramerateStart, "number", "All values should be numbers.");
ok(currFramerateStart <= 60, "All values were correctly clamped.")
prevFramerateValue = currFramerateStart;
}