Skip to content

Instantly share code, notes, and snippets.

@ispern
Last active December 17, 2015 21:29
Show Gist options
  • Save ispern/5675447 to your computer and use it in GitHub Desktop.
Save ispern/5675447 to your computer and use it in GitHub Desktop.
show FPS - Sencha Touch 2.2
Ext.Viewport.add([
{
id : 'currentFPS',
xtype : 'component',
bottom: 0,
right : 0,
width : 50,
height: 50,
style : 'background-color: red; color: white;'
},
{
id : 'averageFPS',
xtype : 'component',
bottom: 0,
left : 0,
width : 50,
height: 50,
style : 'background-color: green; color: white;'
}
]);
var fpsIndicator = Ext.getCmp('currentFPS'),
fpsAverage = Ext.getCmp('averageFPS'),
fpsCount = 0,
fpsSum = 0;
Ext.AnimationQueue.onFpsChanged = function(fps) {
fpsCount++;
fpsSum += fps;
fpsIndicator.setHtml(Math.round(fps));
fpsAverage.setHtml(Math.round(fpsSum / fpsCount));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment