How efficient is accessing data tables?

Deamonpog
Wed, 12 Jul 2017 08:18:09 +0000
Debugging, Optimization, & Profiling

I would like to know how efficient it is to:

1. Search for a data

2. Get data by row name

Is it O(1) or O(n) ? Do I have to manually cache Data Table in memory or will they be cached into memory at runtime?

Imagine I have to implement an item inventory system for an RPG.

Data Table Method:
I could save all basic data related to all items such as Name, Type, Value, Weight and Static Mesh Reference, in a Data Table. Then I can have a common class/object and assign these values from data table at runtime when needed. (there will be many Get Data Table Row calls). However, unique items need to have their own classes.

OOP Method:
Create basic item class and all items inherit from it as a separate class. Unique items are dealt the same way.

Which method above will be efficient in time ? and in space ?

17 posts - 12 participants