<fx:AnandVardhan/>

lights..camera..Action..Script.. ing..

Flex Performance Tuning Tips

Posted on | June 27, 2007 |

Flex Speed Tips: Matt chotin has shared a some great tips to improve Flex performance which I came through and would like to share with the community,

  • If you have a type in AS3, which you are not sure of always use the As operator to cast the type before you use it. This avoids VM errors with try/catch, which slow the execution and is ten times slower than the As operator.
  • Array is access is slow if the array is sparse. It may be faster to put nulls in empty values as this speeds things up. Array misses are very slow, up to 20 times slower than finding a valid entry.
  • Avoid implicit type conversion. In the player it will convert integers to numbers and back when asked to add integers. You might as well use numbers for everything and convert back to integer at the end.
  • Local variable access is faster, so assign variables to local if they are accessed a lot. They will be stored on the stack and access is much quicker.
  • Data Binding expressions take up memory and can slow down the application startup. It may be more efficient to do an assignment in code rather than using binding.
  • Find a slow computer and run your application. If it runs OK ship it! Other wise you can use flash.utils.getTimer():int to get a time value in miliseconds before and after some process to time it.
  • In Flex Builder 3 there is a profiler that allows you to take performance snapshots to record how long was spent in each function. This is useful to identify the areas of code that might benefit from optimization. While profiler is running everything is much slower. Often Mouse or similar Events will seem to take lots of time, you can ignore these. Investigate your own functions and see if they have been called too often or they take too long.

Comments

4 Responses to “Flex Performance Tuning Tips”

  1. Burak KALAYCI
    June 28th, 2007 @ 2:44 am

    AFAIK, local variables are mostly stored in registers (as opposed to the operand stack). On the other hand, if the stack referred is not the VM stack but the real application stack, I wouldn’t know about that.

    Anyway, even if I’m wrong, this is not important in this context - Local variable access is surely faster.

    Best regards,
    Burak

  2. Tony
    June 30th, 2007 @ 10:01 am

    Thanks for the tips! :)

  3. greg h
    July 9th, 2007 @ 2:27 am

    Anand,

    Thank you! Excellent, easily usable list!

    Just curious, could you confirm that your source for this was the Matt’s presentation slides (PDF) at this link:
    http://weblogs.macromedia.com/mchotin/archives/2007/06/slides_and_samp.cfm
    and now downloadable here too:
    http://www.adobe.com/devnet/flex/articles/as3_tuning.html

    Again, thanks!

    g

  4. Anand Vardhan
    April 17th, 2008 @ 3:02 am

    Hi,

    I am also a learner buddy, i read this somewhere and compiled it in a sequence.

    I thoght it would be helpful for beginners so shared it.

    Here I am not writing copyrights.

Leave a Reply