Jump to content


Photo

Performance Questions


  • Please log in to reply
3 replies to this topic

#1 mrokke96

mrokke96

    GMC Member

  • New Member
  • 256 posts
  • Version:GM8

Posted 25 February 2012 - 05:05 PM

hi, i just have some questions about optimal performance, soo, which is the fastest(or no different at all):
1. Code or Drag & Drop?
2. If i have like 1000 tiles or If i have 1000 objects WITHOUT any actions in it?
3. Script or Code(if i put a long code in a script and then run the script in a code)?
4. If i have a room which is 1000*1000 and i have a large background or If i have a small background but in room settings i set so it tiles the entire room?
5. If i use tiles to cover the room(like a background) or If i set a normal background so it covers the whole room?

im just curious to know so i can have the optimal performance in my game :D
  • 0

#2 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3491 posts
  • Version:GM:Studio

Posted 25 February 2012 - 05:16 PM

Differences marked as
^s - small difference, not really worth dealing with.
^m - medium difference, might be wise to fix it if in performance-critical section of game.
^l - large difference, better fix it if you can.

1. Tests have shown that D&D is equivalent to code, apart from few cases like comparisons, because all D&D actions must have a function behind it, thus your "if x > 0" D&D block is threatened as "if action_if_variable(x, 0, 2)" by runner. ^s
Edit: yes, -every- D&D action has it's own function. If you do menu:Scripts\Show built-in functions, you can see these in list prefixed as action_.
2. Tiles will be faster, because GameMaker automatically decides if they need to be drawn, and will not draw them outside of view. ^l
3. Technically object event is working -a bit- faster than a script. I cannot tell if moving all your scripts into object events is a good idea though. ^s
4. Due to nature of DirectX, GameMaker draws large backgrounds faster than a small ones. To test this, compare CPU usage of room with a 4x4 tiled background, and 512x512 background with is made of tiled 4x4 ones ^l
5. See above, normal background would work faster, unless your tiles have size same as background. ^m

Edited by YellowAfterlife, 25 February 2012 - 05:17 PM.

  • 1

#3 mrokke96

mrokke96

    GMC Member

  • New Member
  • 256 posts
  • Version:GM8

Posted 25 February 2012 - 05:22 PM

Differences marked as
^s - small difference, not really worth dealing with.
^m - medium difference, might be wise to fix it if in performance-critical section of game.
^l - large difference, better fix it if you can.

1. Tests have shown that D&D is equivalent to code, apart from few cases like comparisons, because all D&D actions must have a function behind it, thus your "if x > 0" D&D block is threatened as "if action_if_variable(x, 0, 2)" by runner. ^s
Edit: yes, -every- D&D action has it's own function. If you do menu:Scripts\Show built-in functions, you can see these in list prefixed as action_.
2. Tiles will be faster, because GameMaker automatically decides if they need to be drawn, and will not draw them outside of view. ^l
3. Technically object event is working -a bit- faster than a script. I cannot tell if moving all your scripts into object events is a good idea though. ^s
4. Due to nature of DirectX, GameMaker draws large backgrounds faster than a small ones. To test this, compare CPU usage of room with a 4x4 tiled background, and 512x512 background with is made of tiled 4x4 ones ^l
5. See above, normal background would work faster, unless your tiles have size same as background. ^m

okey thanks!
  • 0

#4 kburkhart84

kburkhart84

    GMC Member

  • GMC Member
  • 1608 posts
  • Version:GM:Studio

Posted 26 February 2012 - 04:53 PM

As far as #3 is concerned, technically the event code would be faster. But, if there is a lot of code there, and/or you are using the same or similar code in other objects, you are better to put it in scripts and call the script. Why? Because that slight script calling overhead is very small compared to the benefit of not repeating code. Also, you can open the script from the tree browser thing on the left, and to get to the object code you have to open the object, then the right event, then the window, and also, atleast for the moment, the dialog that opens for said object event code is blocking everything else, but the one for "normal" scripts does not.

For #2, and the rest, I'd say Yellow is right. Remember, GM creates a lot of things for objects, whether you have events or not, an object has to have all of the default variables. All of that variable creation has a slight price, and all of the updating does too, even if it is just a quick check to see if the object has a speed or not in order to move it. But, if you are using an array and using tiles to draw all of those objects, and you are moving and animating those objects, that is probably OK, and faster than normal objects. But remember you lose the event system like that, so you have to check your own collisions, and also, you are probably better off to simply draw sprites instead of tiles.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users