Created
October 26, 2012 22:11
-
-
Save micahcatlin/3961866 to your computer and use it in GitHub Desktop.
Fragment for measuring fps, heap size on Chrome
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
| function() { | |
| var lastHeapSize = null; | |
| var lastFrameTime = null; | |
| var runGame = function() { | |
| requestAnimationFrame(runGame); | |
| var frameTime = window.performance.now(); | |
| var heapSize = window.performance.memory.usedJSHeapSize; | |
| if (lastHeapSize == null) { lastHeapSize = heapSize; } | |
| if (lastFrameTime == null) { lastFrameTime = frameTime; } | |
| var dt = frameTime - lastFrameTime; | |
| var dh = heapSize - lastHeapSize | |
| frameDataList.push([dt, dh]); | |
| lastHeapSize = heapSize; | |
| lastFrameTime = frameTime; | |
| computeNextGameStateAndPaint(); | |
| }; | |
| }(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment