Just write it briefly;
The method that Lua calls Java, there are two kinds in luaj.
1 using the Luajava library provided by the official
Local " Com.test.lj.TestClass ");
Ins:test ()
2 self-binding method, using the same way as the original Lua method
local ins = testclass.new ()--new method binds itself ins:test ()
Which method is good?
Conclusion:
Surprisingly, the performance of the Luajava library reflection call is, in some cases, faster than the Java native binding.
1 in cases where the number of object methods is relatively small, the method of the Luajava generated class executes faster than the Java binding, but essentially the same.
2 in the case of many object methods (complex objects), the Luajava generated classes are slower to execute than the Java bindings (possibly an unrelated method), one of my test objects executes the result, Luajava is about 1.5:1 faster than Java
3 The speed of object creation, Java binding Dingyuan is better than Luajava, the base is close to 2:1 relationship;
Selection suggestions:
If it is an accidental use of an object, it is recommended to use Luajava, convenient, fast and not bad
If it is a frequently new object or complex object (but actually using only partial methods), it is recommended to use Java binding
(if necessary, leave a message; I put the test code up)
Luaj calling Java Method Performance research