lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I'll build some performance benchmarks of it and post some example
> code later today.

This is the object machinery I use in my game right now.

 http://www.chat.net/~jeske/Projects/ScriptPerf/download/obj_machinery.lua

Here is a test file which runs some basic functionality and
performance tests on the machinery:

 http://www.chat.net/~jeske/Projects/ScriptPerf/download/obj_test.lua


The biggest problem I have with it is that it is a very "lazy"
scheme. That is, it does not copy data into the instance unless you
change the data. This causes lots of lookups into your classes at
runtime for any instance data you have not written locally into your
instance. It does cache the LOCATION that it found the data, so it
only has to do a traversal of the inheritence tree for a given piece
of instance data ONCE.

I have been considering changing the scheme either to copy data into
the instance to improve performance. This would either (a) just copy
the data, in which case you would lose any connection with the class
data. Chainging the class data would either only affect new instances,
or affect instances which had not yet accessed that data, or (b)
require that I make some kind of invalidation scheme, where touching a
piece of class data would invalidate the copies of that data (probably
not worth the storage space it would cost).

Here are some performance benmarks:

mozart:~/public_html/Projects/ScriptPerf/download> lua obj_test.lua
instance_data_access_test       500000  elapsed:        2.31381
cached_parent_data_access_test  500000  elapsed:        25.3167
missing_instance_data_access_test       500000  elapsed:        20.0927


mozart:~/public_html/Projects/ScriptPerf/download> ./all_test.py
instance_data_access_test(500000) elapsed: 2.87970805168 seconds
class_data_access_test(500000) elapsed: 3.36563897133 seconds
missing_instance_data_access_test(500000) elapsed: 4.23586905003 seconds



-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net