Which one is faster table or game attributes?
SEMA
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
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'm on the edge of my seat!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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
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 !