Created
January 18, 2018 19:56
-
-
Save bitnenfer/70dff6cdd8a495c9bcf0c324e33fe5f2 to your computer and use it in GitHub Desktop.
FPS
This file contains hidden or 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
| 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