A few days ago i decided to restructure my game using the unity plugin.
The idea was to outsource many arrays into lua tables, because they are much more flexible.
Now, a few days later, I decided to make a little speed test on the "lua get [type]"-commands.
I was shocked Oo
While getting a variable from the lua environment took 2,3 seconds the same procedure using normal dbp variables only last 0,09 seconds.
Here the test program:
REM LUA TEST
err=lua execute("test=1")
starttime = timer()
for x=0 to 10000000
y=y+ lua get int("test")
next x
endtime = timer()
time# = (endtime-starttime)/1000.0
print "Lua time: ";time#
REM NORMAL TEST
test=1
starttime = timer()
for x=0 to 10000000
y=y+test
next x
endtime = timer()
time# = (endtime-starttime)/1000.0
print "DBP Variable time: ";time#
wait key
I planned to control my whole game by values i get from the lua environment, is this the end of my dream?
EDIT: i now tested the whole thing with requesting an array entry and it lasts 31 seconds :o
REM LUA TEST
err=lua execute("test = {test=1}")
starttime = timer()
for x=0 to 10000000
y=y+ lua array int("test->test")
next x
endtime = timer()
time# = (endtime-starttime)/1000.0
print "Lua time: ";time#
wait key