it's only me or when using "oop" in lua the performances are much more slower ?
i mean... i tryed to convert my "raw" collision functions in a better and beauty oop code...
i extended sprite class adding only collision methods (C++ plugin) but the performances are about 2-3 times slower than the "pure" collision functions!
your experience with lua + oop ?
TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
www.tntengine.com
Comments
yes... oop is always slower
but in lua is a little too much slower !
www.tntengine.com
agree with @GregBUG 2-3 times is too slower
Likes: Nascode
my collision system is much "easier" when used in oop!
but it's a time critical code so if i use oop i lose the boost of c++ code !!
...
to "oop" or not to "oop"!! that is the question !
www.tntengine.com
www.tntengine.com
I mean, being lua a multiparadigm language there are different ways to understand and implement OOP and Gideros has chosen one. Do you know if there are sensitive differences in performance terms depending on the OOP implementation type in lua?
(i.e, see different techniques in http://lua-users.org/wiki/ObjectOrientedProgramming)
@Lobo lets ask @atilim for your question
http://www.nightspade.com
Personally I've found Gideros' oop structure very elegant and clear, and in general all the framework gives you the feeling of something well designed and sensitive towards the developpers, it's easy to structure your code, it's easy to decide how to organize mentally your work and keep a global logic for your app, which for me it's very important in order to advance. At least for me oop it's basic for that and It would be a pity if for some uses performance differences would be sooooo important...
ex:
mySprite:boxToBox(spriteB.x, spriteB.y, spriteB.w, spriteB.h)
the same thing using procedural is:
boxToBox(spriteA.x, spriteA.y, spriteA.w, spriteA.h, spriteB.x, spriteB.y, spriteB.w, spriteB.h)
called in a simple "for" loop
(check "maxBox" Sprites for collision with every sprite on screen...)
procedural code took about 300ms
oop code about 950ms
in this case oop is too slow!
(ps: BTW i'm a noob on lua OOP)
what do you think ?
@atilim ? there is space to optimize Lua OOP ?
www.tntengine.com
In TNT, the best thing might be to provide a function that does multiple collision detections rather than the Lua programmer going through a loop. Its best not to have lengthy nested loops in Lua, that's when the interpeted nature of Lua really causes trouble!
If you were to provide such a function, I'm guessing the OO/imperative thing wouldn't matter so much...?
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
I'm curious how much better (or worse) the performance is going to be if you reduce the table lookups to using a local variable (even in the procedural case):
Try
not noticeable differences.... (tested only on desktop player BTW)
but creating a local variable inside a loop slows down the performance right?
www.tntengine.com
> creating a local variable inside a loop slows down the performance right?
It does, but the payoff for not doing a table lookup (especially multiple times) should be larger. It may even be better to allocate the variable outside of the loop and just assign the value to it.
btw, you have some code (like "n=n+1") commented out in the procedural, but uncommented in the OOP version. Is it just in the post or in the actual test too?
the test code executed is the same
ps: in the procedural version your modification speedup a little bit (310ms vs 380-390ms per frame)
www.tntengine.com