Which one is faster table or game attributes?

SEMASEMA Member Posts: 161

Which one is faster table or game attributes?
I have a project which has a lot of game attributes it takes some time to find them are tables faster in performance?

Comments

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,155

    Game Attributes are faster, table attributes are more flexible. You'll need to find a balance.

  • SocksSocks London, UK.Member Posts: 12,822

    @adent42 said:
    Game Attributes are faster, table attributes are more flexible. You'll need to find a balance.

    Unrelated to SEMA's question, but a while back I was doing a lot of testing and found that self.attributes were faster than game.attributes, well 'faster' might not be the right term, more efficient is probably a better description, basically I was running a lot of actors with quite a few Constrain behaviours in each one, and found that I could keep the frame rate happily at 60fps when using self.attributes, whereas with game.attributes the frame rate would occasionally dip below 60fps. This was tested in lots of different situations with separate projects, and the results were similar throughout, and generally speaking the projects were pushing GameSalad right to the edge (lots of things going on).

    Is there anything to this, or have I finally gone mad ?

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

    @Socks said:
    Is there anything to this, or have I finally gone mad ?

    I'm on the edge of my seat!

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

  • ArmellineArmelline Member, PRO Posts: 5,354

    As a side note, a good tip: If you have lots of self attributes, and need to use a few of them regularly but find them hard to locate, add an emoji or other special character to the start. Makes it much easier to pick them out of a list.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    must have something to do with the scan. I imagine it is condensed in the general scan of an actor and it's other self attributes.

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    @Socks said:

    @adent42 said:
    Game Attributes are faster, table attributes are more flexible. You'll need to find a balance.

    Unrelated to SEMA's question, but a while back I was doing a lot of testing and found that self.attributes were faster than game.attributes, well 'faster' might not be the right term, more efficient is probably a better description, basically I was running a lot of actors with quite a few Constrain behaviours in each one, and found that I could keep the frame rate happily at 60fps when using self.attributes, whereas with game.attributes the frame rate would occasionally dip below 60fps. This was tested in lots of different situations with separate projects, and the results were similar throughout, and generally speaking the projects were pushing GameSalad right to the edge (lots of things going on).

    Is there anything to this, or have I finally gone mad ?

    I think this is fundamental to programming optimization.

    Although i'm not familiar with GS codebase, in most programming languages it is more inefficient to declare and use a global var than a local var because of the "scope" of the var. A global var is able to be used by ANY actor, object, function, etc... or basically it is always in scope, and by effect usually uses more resources, or makes for worse programming habits.

    Local on the other hand is ONLY scoped to the actor (or in programming languages, the current function.) So it may not be called as often or "checked" as often or misused.

    This doesn't mean you shouldn't ever use "global" vars, just to use them appropriately.

    See: Global Vars Are Bad

    Also: Game Programming Patterns

    The above book is worth the read, even as a visual scripting programmer, the concepts are applicable. And it's free.

    Follow us: Twitter - Website

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2017

    @AlchimiaStudios said:

    @Socks said:

    @adent42 said:
    Game Attributes are faster, table attributes are more flexible. You'll need to find a balance.

    Unrelated to SEMA's question, but a while back I was doing a lot of testing and found that self.attributes were faster than game.attributes, well 'faster' might not be the right term, more efficient is probably a better description, basically I was running a lot of actors with quite a few Constrain behaviours in each one, and found that I could keep the frame rate happily at 60fps when using self.attributes, whereas with game.attributes the frame rate would occasionally dip below 60fps. This was tested in lots of different situations with separate projects, and the results were similar throughout, and generally speaking the projects were pushing GameSalad right to the edge (lots of things going on).

    Is there anything to this, or have I finally gone mad ?

    I think this is fundamental to programming optimization.

    Although i'm not familiar with GS codebase, in most programming languages it is more inefficient to declare and use a global var than a local var because of the "scope" of the var. A global var is able to be used by ANY actor, object, function, etc... or basically it is always in scope, and by effect usually uses more resources, or makes for worse programming habits.

    Local on the other hand is ONLY scoped to the actor (or in programming languages, the current function.) So it may not be called as often or "checked" as often or misused.

    This doesn't mean you shouldn't ever use "global" vars, just to use them appropriately.

    See: Global Vars Are Bad

    Also: Game Programming Patterns

    The above book is worth the read, even as a visual scripting programmer, the concepts are applicable. And it's free.

    Great info AlchimiaStudios ! . . . So my test results weren't just the product of all that Pinot Noir ! :)

    I agree that there's definitely a place for global variables, there are many many situations where global attributes are definitely the better approach, but where absolute efficiency is concerned local variables seem to have a slight edge.

    Cheers for the input, much appreciated, I'm off to check out the articles you linked to !

Sign In or Register to comment.