playMaker

Author Topic: The best ways to Rome  (Read 3169 times)

FritsLyn

  • Full Member
  • ***
  • Posts: 191
The best ways to Rome
« on: August 21, 2013, 03:59:27 PM »
* Is it faster to use a global variable than injecting a local from another FSM?
* Is it faster to compare an Int or a Float?
* Which basic commands are really fast, and which are really slow?
* Is it better to initialize a couple of smart functionalities to get a short list of commands but a lot of different action types, or to repeatedly call a lot of more basic commands but only initialize a few action types?
* Is a Clamp more heavy than a variable running wild?
* Is Quaternion rotation faster than XYZ?
* Does it take time to fetch a GameObjects position over storing/retreiving the value?
* etc..

Basically: What is known to be heavy, and what is known to be light - we are talking optimization, CPU time.

I guess when developing, you guys are looking into these things somehow, every now and then, seeing that some things are just heavy because of the nature, and some things are light.

And then it'd just be awesome to get any type of tip/list you have, all knowledge that can help because there are often many ways to do the same thing, and so it'd be nice to know what is faster when speed matters.

Thanks :)

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: The best ways to Rome
« Reply #1 on: August 28, 2013, 03:19:09 PM »
Is it causing overload to have multiple GameObjects running small routines with "Next frame event" instead of one large routine with only one?

No such lost-o-hints Alex / Jean? :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: The best ways to Rome
« Reply #2 on: September 10, 2013, 03:12:42 AM »
Hi,

* Is it faster to use a global variable than injecting a local from another FSM?
Yes, it's faster, but I don't recommand it UNLESS it's clearly the job of a global variable. Too mayn times, developers use Global variabe for what really should be the job of a Fsm hosting a local variable and have it accessed directly by other fsm. So here, even if it may be faster, I definitly do not recommand it as a reflex...

* Is it faster to compare an Int or a Float?
not relevant. The difference in perfs will never be noticable

* Which basic commands are really fast, and which are really slow?
notorious slow command is to create/delete objects, create/delete component and search for gameObects using "find", so use it very carefully if you must.

* Is it better to initialize a couple of smart functionalities to get a short list of commands but a lot of different action types, or to repeatedly call a lot of more basic commands but only initialize a few action types?

* Is a Clamp more heavy than a variable running wild?
it depends your need, that's alread down to your logic needs

* Is Quaternion rotation faster than XYZ?
yes,

* Does it take time to fetch a GameObjects position over storing/retreiving the value?
what do you mean?

* Is it causing overload to have multiple GameObjects running small routines with "Next frame event" instead of one large routine with only one?
Yes, but that's the deal with Object oriented programming... It's really an issue with numbers. I tend to always start with a true object oriented approach, and then I optimzed, if I find an object that is process and duplicated too many times, then I'll optimized, doing the opposite will result in a messy project, with only "managers" trying to do it all which in turn isn't very performant in the end, but far more worse, totally unscalable and ready to throw in the bin as is... so prefer OOP, then move back to managers IF you can prove this is the bottle neck...

You'll find that 90% of the time, it's your physics set up that takes too much process or the rendering ( bad mesh optimization, wrong shaders, general scene handling)


Bye,

 Jean