Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

What are some good ways to squeeze in more fps in your app

edited October 2013 in Questions Posts: 577

Hi, I think the fps counters will be the death of me. As im worried my fps aren't good enough (58, 60)

So, to help out the community and me, what are some good tips/tricks to get higher fps.

Thanks, Prynok



  • IgnatzIgnatz Mod
    Posts: 5,396

    lol, I only start worrying when it gets below 25. Since 60 is the max, and we can only detect 30 or so, anything higher should be fine.

    Optimising your speed depends a lot on what's in your project.

  • Jmv38Jmv38 Mod
    Posts: 3,297

    Drawing is uually the main fps budget.
    You can improve it to very nice perf by
    1/ drawing things once to an image 2/ sprite the image where you need.
    This is relly better than drawing each time. And use noSmooth().
    Also: put collectgarbage() whereever you dereference big objects. This will smooth the resulting pace. Otherwise you may get an ugly1s stop from time to time.

  • Posts: 1,595

    Localise tables/variables and anything else you can think of, if any heavy loops are used then try and localise the containing code as it makes it quicker to process as its stored locally in a function instead of globally

  • The key is: identify which bit of code is the bottleneck. Othwerwise you'll just end up optimising things that aren't actually slowing you down.

    This can be tricky to do in Codea, but an approach of disabling bits one by one and seeing when the speed comes up can work.

  • edited October 2013 Posts: 398

    As well as judicious use of 'local' variables, I tend to avoid some of the built in table iterator functions (table.insert, table.remove, ipairs etc..) and use simple 'for' loops to iterate through to the end of the table (with #).

    This can be a lot faster, especially if you need increased performance in your main game loop, albeit at the expense of readability of your code.

    There was a really good thread on StackOverflow a while back that runs through a number of Lua performance optimisation tips:

    Also, some good general Lua performance tips (explained in a fairly non techy under the hood way) here:

    Hope this helps..


  • Posts: 1,595

    Keeping a index on the table in a seperate variable which gets added to every time the table is added to is a quicker way of finding the sum of the table, # does this calculation in one frame which is slower, but about 0.1fps slower ;)

  • Posts: 2,820

    I seriously emphasize using noSmooth() if drawing large shapes. For instance, I'm drawing fullscreen rectangles, and using noSmooth makes me go from 50 FPS to about 15 FPS. Also, suggest using meshes for some things, but only if you're using many of the same object.

Sign In or Register to comment.