Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How do i display fps — Gideros Forum

How do i display fps

hnimhnim Member
edited February 2012 in General questions
Hi, i want to test performance of my game. How do i display fps on game screen or print log?
thanks :)

Comments

  • yes, is there any way to calculate this value?
  • GregBUGGregBUG Guru
    edited February 2012
    on onEnterFrame(event)
    function onEnterFrame(event)
        local fps = 1/event.deltaTime  
        print(fps)
    end
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • If you're using an iPhone, and run the GiderosiPhonePlayer from Xcode with the iPhone plugged in, it shows fps on the debug console.

    I don't know if there's the same facility with Android.
  • Thanks GregBUG :)
    If i build and run project from eclipse, i can see fps in logcat
  • atilimatilim Maintainer
    edited February 2012
    Hi,

    The fps seen in Xcode console and logcat uses a algorithm like:
    local frame = 0
    local timer = os.timer()
    local function displayFps()
    	frame = frame + 1
    	if frame == 60 then
    		local currentTimer = os.timer()
    		print(60 / (currentTimer - timer))
    		frame = 0
    		timer = currentTimer	
    	end
    end
     
    stage:addEventListener(Event.ENTER_FRAME, displayFps)
    (It's same with @GregBUG's but averaged through 60 frames)
  • hnimhnim Member
    edited February 2012
Sign In or Register to comment.