0

I was thinking of adding some native code to my Android application, but I wanted to find out if it's worth it and if JNI calls are currently optimized. The function calls would involve transferring information from Java to native code and back.

Knowing this would save a lot of production time. Thanks!

Kofi
  • 525
  • 6
  • 15
  • Are you ***actually*** having *any* measurable performance problems? Just go with whatever is easiest to implement and *then* check if your performance is bad / worthy to improve / worry about. – luk2302 Aug 18 '22 at 15:59
  • @luk2303 I haven't tried both methods yet since doing that takes quite a lot of time. However, having a fair idea of both would help greatly. For instance, if JNI has a significantly lower overhead then I'd just go ahead and use it since that would save time as compared to trying both methods and then comparing them – Kofi Aug 18 '22 at 16:07
  • Your question is too vague to answer. Yes, making a JNI call is a lot more expensive than a standard method call. But in return you get to use native libraries and native code directly. Rewriting a hot loop in native code might be worth the trouble, but you only know that *after* you did everything you could in Java-land. In short: treat JNI as the only way to use native libraries and/or the ultimate optimization for hot loops. – Botje Aug 18 '22 at 17:53

0 Answers0