Skip to content

Instantly share code, notes, and snippets.

@ganglio
Created September 20, 2013 16:42
Show Gist options
  • Save ganglio/6640365 to your computer and use it in GitHub Desktop.
Save ganglio/6640365 to your computer and use it in GitHub Desktop.
Calculate the current website FPS
(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