playMaker

Author Topic: A list of expensive action v cheap ones?  (Read 1922 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
A list of expensive action v cheap ones?
« on: November 22, 2019, 07:28:35 AM »
An excel spreadsheet listing all actions along with their millisecond count, would be super handy for devs to decide which approach to script things with.

For example: when the player acquires a new item, I have a 26 hash tables named after each letter, where I store prefabs of each item. Should I have a parent AllPrefabs game object where I say, "find child named b" then get the entry from the b hash table, or should I have a SEPARATE hash table with 26 entries, where I just "hash table get" the one with a key of b?

In other words, which is more expensive: find child, has child, or hash table get?

A way for devs to rank the actions by expense would be very handy for optimizing the script profiler.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: A list of expensive action v cheap ones?
« Reply #1 on: November 25, 2019, 01:13:41 AM »
Hi,

 it's impossible to do such list in a meaningfull way, because it depends on the depth of the hierarchy.

find a child where you have only 1 child is fast, find a child within a 100 levels with thousands of childs across each of these levels, and that's going to be a slow process.

the best approach is trial and error. I always first develop what I want, regardless of perfs, then when it works, I check with the profiler to see if it's sound, and if it's not, then and only then, I refactor. This way will save you a lot of time.

Resources would be best in your case, adopt a naming convention for your prefabs, put them all inside a resources folder ( custom actions available on the ecosystem system to load resources), and load what you need on demand, this way, you only load in memory what you need, your solution requires All prefabs to be loaded in memory which will make for a slow level loading and probably too much memory consuption for what's really needed.


Bye,

 Jean