Created
September 20, 2013 16:42
-
-
Save ganglio/6640365 to your computer and use it in GitHub Desktop.
Calculate the current website FPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
"use strict"; | |
var filterStrength = 20; | |
var frameTime = 0, lastLoop = new Date, thisLoop; | |
var loop = function() { | |
var thisFrameTime = (thisLoop=new Date) - lastLoop; | |
frameTime+= (thisFrameTime - frameTime) / filterStrength; | |
lastLoop = thisLoop; | |
window.requestAnimationFrame(loop); | |
} | |
setInterval(function(){ | |
console.log((1000/frameTime).toFixed(1) + " fps"); | |
},1000); | |
loop(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment