Overhead for types?

Blitz3D Forums/Blitz3D Beginners Area/Overhead for types?

BulletMagnet(Posted 2004) [#1]
I am thinking of doing the following to support an editor for my gameobject parameters.

Type GO_paramInt; There are also a STR and Float version of GO_Params.
  field name$; The parameter's readable name like RemainingArmor or BlastRadius.
  field docText$; Appears as tooltip or parameter help text in an editor.
  field value%; the parameter.
  Field defaultValue%; a default if any. May remove this and just have it stored in the script file to be accessed as needed.
end type

Questions:
1. What is the memory/performance overhead when creating thousands of types?

2. What overhead is there for unused or uninitialized type fields? i.e. Is field memory allocated when the type instance is created even if the fields are unused?

3. Got a better idea?

I arrived at this after reading about DungeonSiege development and Data-Driven game design.

Thanks,


soja(Posted 2004) [#2]
Note: Much of this is speculation and not necessarily based on fact

1) If you're just talking *overhead*, it's probably not too much. Maybe 20 bytes or something, if that (next pointer, previous pointer, some other sundry items)

Why don't you test it? Create 1000 types, check out memory usage of the program, then repeat with 2000 types, take the difference, divide by 1000, subtract what's required for your own field(s), and see what you get. It's an idea, anyway.

2) Yes, I think it would be allocated even if it's not "used" (otherwise you'd end up with a ton of fragmented memory).

I think that most of the perf hit comes on creation of the first set, becasue even if you delete them, Blitz does not release the memory, but keeps it around in case you want to create more types (and so it won't have to allocate more memory).


BulletMagnet(Posted 2004) [#3]
Thanks Soja.
Yeah, my next step was to build up a quick test but I was curious to see if anyone had some good data on it.


ryan scott(Posted 2004) [#4]
types are basically linked lists, which are going to be a lot easier to manipulate than a collection of arrays that would do the same thing.

they are so useful, you should always use them.

they are pretty ridiculously fast. while you might get a little speed boost using arrays, but primarily only when you know which object you are after, it's not worth it.

most of the time you'll be iterating through all of a certain Type, and having them in an array wouldn't really get you much speed.

use them. its somewhat unlikely you'll develop a game where the processor speed is what's holding you back, unless you write it really crappily. saving anything by using something other than types won't be worth it.

ok, not very specific regarding numbers, but i'm telling you, it doesn't matter, types are the way to organize all the data in your program and as it gets larger you'll find it would have been more difficult to code without them.