A Flash Developer Resource Site

Page 12 of 21 FirstFirst ... 28910111213141516 ... LastLast
Results 221 to 240 of 411

Thread: Optimization Tips

  1. #221
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928


    You know that people who talk about it the most aren't actually having it.

    I only use that term so often cause the phrase "Donkey on woman action" is hard to slip into a sentence about actionscript.

    Enough spam from me.

    Squize.

  2. #222
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    Check "io::pred" and PrED32 Strille =)

  3. #223
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182

    :)

    Originally posted by strille
    Btw Squize, I'm naming you the current champion of the use of the word "sexy" in your posts:

    Saphua: 1 (381 posts)

    If someone can find a Games member with a higher count before this post was posted, let me know
    Hehe this is the first time I look in this threath.. finding ways to improve my code for SaphuA... sum pretty handy stuff in here ...


    Oh and damn... are you sure I only used sexy once? I mean, I'm very sexy, atleast sexy'er then a sexy person who think's he's very sexy...

    And you know what? Yesterday a sexy girl walked by... and I walked (using my sexy walk) to her, saying:
    "Hey! sexy... I was just thinking, woohoo you sure are sexy" and the sexy girl walked to me (using her sexy walk asswel) and then with a smooth sexy move... SHE STOLE MY sexy HOTDOG!!!
    Now that sure was NOT sexy at all...

    I think it's time to update your sexy list, sexy Strille

    Greetz,
    sexy SaphuA
    Last edited by SaphuA; 09-01-2003 at 01:48 PM.

  4. #224
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    Sorry SaphuA, remember: "If someone can find a Games member with a higher count before this post was posted, let me know"

    I think we have to take this to the Coffee Lounge soon

  5. #225
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182

    :)

    d0h!

    My post was before your post... only FK was slow, and I could look in the future

  6. #226
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182

    WHY!!!!

    Hey,

    I was just playing with things for my ISO game and checking everything what will be slightly faster...

    Now I came across this code:
    code:

    //---------------------------------------
    time = getTimer();
    var y = 0;
    while (y<2000/20*40) {
    y++;
    }
    trace("Action 1: "+(getTimer()-time)+"ms");
    //---------------------------------------
    time = getTimer();
    var y = 0;
    var yy = 2000/20*40;
    while (y<yy) {
    y++;
    }
    trace("Action 2: "+(getTimer()-time)+"ms");
    //---------------------------------------
    time = getTimer();
    var y = 0;
    while (y<2000/20*40) {
    y++;
    }
    trace("Action 1: "+(getTimer()-time)+"ms");
    //---------------------------------------
    time = getTimer();
    var y = 0;
    var yy = 2000/20*40;
    while (y<yy) {
    y++;
    }
    trace("Action 2: "+(getTimer()-time)+"ms");
    //---------------------------------------



    I don't get why action 2 is slower... it should be faser, right? Xplain plz

  7. #227
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    It's because 2000/20*40 is never calculated at run time, it's saved in the .swf as 4000. y<4000 is faster than y<yy because in the first you have one variable and one constant while you have two variables that need to be compared in the second.

  8. #228
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182

    :)

    Thnx ,

    So:
    code:

    var bleh = 16*12/9+6; //Is pre-calculated?



    Then how about:
    code:

    var X = 16;
    var Y = 12;
    var bleh = X*Y/9+6; //Is this also pre-calculated?


  9. #229
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    The first example is pre-calculated but I don't think the second is.

  10. #230
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    I'd actually think it was since it is not exclusivly updating x/y at any time, it simply isn't hardcoded.

    RipX

  11. #231
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    I don't know what this proves, but if you compile a new movie with the code:
    code:

    var X = 16;
    var Y = 12;
    var bleh = 16*12/10+6;


    or the code where you have calculated the value instead:
    code:

    var X = 16;
    var Y = 12;
    var bleh = 25.2;


    ...you get the same file size (79 bytes in my case). But this will result in a file that's 101 bytes:
    code:

    var X = 16;
    var Y = 12;
    var bleh = X*Y/10+6;


    Which makes me believe that the last example is not pre-calculated but rather calculated at run time depending on X, Y.

  12. #232
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    The file size is increased because the values are pulled out of variables which increases the bytecode size ( The first two snippits simply push values onto the stack, whereas the last one has to push the vars onto the stack and then get there values ).

    As to pre-caluating things, it's a kinda moot point. Any value you use a lot in a loop you define outside it ( Or as much as possible ), and for any totally static value you define as a _global or in your (load) event.

    Squize.

  13. #233
    Junior Member
    Join Date
    Aug 2003
    Posts
    6
    Besides all tricks within Flash, I optimize my SWFs with Flash Optimizer .That IS a good tool.

  14. #234
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    mannnia, are you working for SoftInfinity or something? All your posts up to this point have just been promotion of Flash Optimizer...

  15. #235
    Junior Member
    Join Date
    Aug 2003
    Posts
    6
    how about that I found this tool exceptionally handy and just can't help talking about it!
    btw, here's a good article at http://www.sitepoint.com/article/1108/ for faster Flash. These might be of no secret for those experienced in Flash, but I thought it could help, too.
    Hope it's not making you think I work for Sitepoint, strille?
    regards,

  16. #236
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    ...and I think you're getting filesize optimisation mixed up with code optimisation. As a simple rule of thumb, the faster the code the larger it is. Strange, but true

    Another quick question, nothing major, I'm just curious about it. I've always been lead to believe that the maths functions in Flash are faster than using pre-calculated tables, but does anyone know if that's a 100% true ?
    For anyone who doesn't understand what I'm taking about, would it be quicker to create an array full of sine values than to use Math.sin ?

    No biggie, and I don't really mind not getting an answer, just curious.

    Squize.

    [edit]
    Regards that link you just posted, point 2. Use very few -- if any -- raster graphics.. Kinda put me off reading anymore. I'd rather have a quicker running game than a quicker loading game I'm afraid.
    [/edit]
    Last edited by Squize; 09-04-2003 at 09:49 AM.

  17. #237
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    mannnia, if you're not associated in any way with Flash Optimizer then I am truly sorry. I just think it's peculiar when a new user's first four posts on the forum are revolving around the excellence of a software. I guess it's just that good. Btw, welcome to the forum!

    P.S. Do you work for Sitepoint?

  18. #238
    Junior Member
    Join Date
    Aug 2003
    Posts
    6
    Originally posted by strille
    I just think it's peculiar when a new user's first four posts on the forum ...
    strille,
    well, I guess I am a peculiar new user...
    Thanks for welcoming to the forums!

  19. #239
    Junior Member
    Join Date
    Oct 2003
    Posts
    1

    Optimization techniques

    A few optimization hint to think about (this does NOT affect the compilers optimizations or the size of the file but rather the speed at which the same code in effect is processed at runtime where it really matters):

    First, when using multiplication or division you can always improve the processing speed by using shift operators in their place.


    operator clock ticks
    --------------------------------------------------
    multiplier 30+
    divisor 90+
    shift operators 3 to 6


    Second, try unrolling for loops in processor intense areas. For example: a loop of 1 to 100 can be changed to 1 to 20 stepping by 5. Process the first iteration, then the second iteration+1, the third+2 etc....increment the loop by 5 and start over. This executes the same amount of code per iteration but causes that area of code to process only 20% of what it was doing prior.

  20. #240
    Moderator
    FK Junkie
    TiefighT's Avatar
    Join Date
    Aug 2000
    Posts
    683
    Optimizing Collision Detection - Discussion and Examples

    That thread is from a while back, just forgot to put it in the stickes when we were done with it. Manely goes over improving FPS by optimizing collision detection, with a focus on the centralized w/ bookeeping approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center