Skip to content

Instantly share code, notes, and snippets.

@micahcatlin
Created October 26, 2012 22:11
Show Gist options
  • Select an option

  • Save micahcatlin/3961866 to your computer and use it in GitHub Desktop.

Select an option

Save micahcatlin/3961866 to your computer and use it in GitHub Desktop.
Fragment for measuring fps, heap size on Chrome
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