Luaj calling Java Method Performance research

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.