Will attributes make the game slower?

If i add 100 boolean-attributes for each level in my game, will that make the game slower then if i didn´t have any attributes?

Comments

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited March 2015

    @ErikAuranaune

    In general, yes just about anything you add, that gets used in the game (even some potentially unused things in your project) will affect performance.

    However 100 attributes would not cause a project to crash or be poor performing in most cases.

    Also "booleans" (i believe) also use less bytes then say a "real" attribute.

    Most performance issues come from too many images eating up RAM or too many objects eating up CPU (spawning too many actors, tons of crazy expressions with large equations, etc).

    Best bet to keep performance in check is to test, test, test on the devices using adhoc.

    Follow us: Twitter - Website

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    No, attributes themselves have no effect on game performance (or a negligible effect).

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited March 2015

    @Socks said:
    No, attributes themselves have no effect on game performance.

    You sure about that? I'd imagine it works like any programming language where each variable type has a set byte usage, thus it does have an effect. Not saying it's significant, but it should still impact performance.

    Edit: ah ninja edited for (negligible) I see.

    Yes, it is indeed negligible. Let's say that Booleans use 2 bytes (could be less) and you have 100 active, that's 2x100=200bytes or .2kb of RAM used. even if the Garbage Collector was doing a terrible job and you had 20 scenes each with 100 unique Booleans you'd end up with 4kb of RAM used.

    Follow us: Twitter - Website

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @AlchimiaStudios said:
    Yes, it is indeed negligible. Let's say that Booleans use 2 bytes (could be less) and you have 100 active, that's 2x100=200bytes or .2kb of RAM used. even if the Garbage Collector was doing a terrible job and you had 20 scenes each with 100 unique Booleans you'd end up with 4kb of RAM used.

    4 kb on an 8 million kb device (8GB iPad for example) isn't really going to register, you could even have ten thousand booleans (using your estimated figures = ~400kb) and it would still only weigh in as much as 1 small image file.

    If the question was 'will adding one small, 400kb, image file slow my game down' I'd probably say 'no'.

    Also RAM usage and performance aren't necessarily the same, you can have a 2GB game (in RAM) that runs super smooth at 60fps - and you can have a 12MB game that glitches and stutters along at 22fps. I can't see any reason why having 100 or even 10,000 booleans would slow a game down.

  • ErikAuranauneErikAuranaune Member Posts: 35

    @AlchimiaStudios said:
    ErikAuranaune

    In general, yes just about anything you add, that gets used in the game (even some potentially unused things in your project) will affect performance.

    However 100 attributes would not cause a project to crash or be poor performing in most cases.

    Also "booleans" (i believe) also use less bytes then say a "real" attribute.

    Most performance issues come from too many images eating up RAM or too many objects eating up CPU (spawning too many actors, tons of crazy expressions with large equations, etc).

    Best bet to keep performance in check is to test, test, test on the devices using adhoc.

    How about if i add a self.attribute?
    So instead of having example 10 boolean-attribues, and 10 actors, i have only 10 actors, and each actor has 1 boolean-attribute?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The answer that was already given is that the number of attributes should not have a noticeable effect on your game.

    If you're using 100 attributes, I would strongly suggest using a table to manage them. It's much more efficient (from a human standpoint).

    GameSalad was built to withstand fairly large data sets so unless you're constraining all of those attributes or using tons or timers to make everything happen, you should be fine.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited March 2015

    @Socks said:
    Also RAM usage and performance aren't necessarily the same, you can have a 2GB game (in RAM) that runs super smooth at 60fps - and you can have a 12MB game that glitches and stutters along at 22fps. I can't see any reason why having 100 or even 10,000 booleans would slow a game down.

    Of course they aren't the same thing, and it wasn't implied that they were. Rather RAM is one aspect of performance, as is any other hardware being utilized for running the App. Hence why I detailed CPU usage in my first post as well.

    Now using your 10,000 booleans example, if you told a mobile processor to process 10,000 boolean changes at the same instant, while also completing other tasks it might have some troubles keeping up and would likely stutter or perform slower until it completed it.

    Also if 100 attributes exist, I don't think it's in a state where they merely exist (they are probably being used by a rule, and that means they do factor into the rules usage).

    So attributes and the way they are utilized are part of the Performance as a whole in my opinion. To throw them aside might not be wise, better to understand it then to say essentially say "nah your good, no performance change ever" As every aspect is connected.

    @ErikAuranaune

    Really it comes down to how you are using the attributes, images, sounds, and logic in your individual game. Testing on devices is the most important thing.

    As for 10 actors with 1 self vs 10 global, I can't say. If GS considers a self.attribute to be a a local var and a game.attribute to be a global you might have a performance gain from self. However in the grand scheme of things it's likely not to make or break your game.

    Also if the self.attributes mean you are creating extra actors then if you used globals, not worth it as actors probably have a higher cost then a game.attribute.

    Complex rule sets, loops, behaviours, and large images are more heavily of a weighted factor.

    Follow us: Twitter - Website

  • ErikAuranauneErikAuranaune Member Posts: 35

    @tatiang said:
    The answer that was already given is that the number of attributes should not have a noticeable effect on your game.

    If you're using 100 attributes, I would strongly suggest using a table to manage them. It's much more efficient (from a human standpoint).

    GameSalad was built to withstand fairly large data sets so unless you're constraining all of those attributes or using tons or timers to make everything happen, you should be fine.

    I have been thinking about using table myself, but how to use it as a level unlock system i do not know how to do. I have been trying tho, but no luck..

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Then you need to watch some YouTube tutorials. Google gamesalad [term] where term is something such as tables or high scores or unlock levels, etc.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @AlchimiaStudios said:
    Of course they aren't the same thing, and it wasn't implied that they were. Rather RAM is one aspect of performance, as is any other hardware being utilized for running the App. Hence why I detailed CPU usage in my first post as well.

    Agreed, I always tend to see performance as specifically CPU based, but of course you are right RAM will play a part too, although like I say you can have a 2GB game that runs perfectly smoothly at 60fps and a 2MB game that glitches and stutters along at 20fps, so in that respect I (personally) always separate RAM usage from performance, as the two are not directly related.

    @AlchimiaStudios said:
    Now using your 10,000 booleans example, if you told a mobile processor to process 10,000 boolean changes at the same instant, while also completing other tasks it might have some troubles keeping up and would likely stutter or perform slower until it completed it.

    Agreed, but no one has mentioned asking a processor to process 10,000 boolean changes at the same instant, or even 100 boolean changes at the same instant, the question was simply about having 100 boolean attributes for each level in a game. You could rule out pretty much anything by placing unreasonable demands on the question, can I have 50 images in my game ? 'If you have 50 massive images in your game all flying around the screen at once then your game is going to lag' !!. :wink:

    Just added ~160 booleans to my current project (I would have done more but got bored clicking), it had zero effect.

    @AlchimiaStudios said:
    Also if 100 attributes exist, I don't think it's in a state where they merely exist (they are probably being used by a rule, and that means they do factor into the rules usage).

    Yes, agreed, of course how an attribute is used is important, but the same can be said of anything. I'd agree that rules will have a noticeable effect on performance, but not attributes themselves.

    @AlchimiaStudios said:
    So attributes and the way they are utilized are part of the Performance as a whole in my opinion. To throw them aside might not be wise, better to understand it then to say essentially say "nah your good, no performance change ever" As every aspect is connected.

    Well, I'd still say adding numerous booleans to a game won't impact on performance, in fact it would be hard to even measure other than a fractional increase in memory size (like you say probably just a few kb).

Sign In or Register to comment.