Skip to content

Instantly share code, notes, and snippets.

@bitnenfer
Created January 18, 2018 19:56
Show Gist options
  • Select an option

  • Save bitnenfer/70dff6cdd8a495c9bcf0c324e33fe5f2 to your computer and use it in GitHub Desktop.

Select an option

Save bitnenfer/70dff6cdd8a495c9bcf0c324e33fe5f2 to your computer and use it in GitHub Desktop.
FPS
var fps = {
startTime : 0,
frameNumber : 0,
getFPS : function()
{
var d = Date.now();
var currentTime = (d - this.startTime) / 1000;
var result = Math.floor(++this.frameNumber / currentTime);
if(currentTime > 1)
{
this.startTime = new Date.now();
this.frameNumber = 0;
}
return result;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment