I'd say instead that it doesn't NEED to slow you down.

But if you store your entire scene graph on the native side, but do
all the manipulation of it on the Java side, with a lot of Java->Java
calls dispatched by the JNI layer in between, and lots of arrays
getting locked or copied -- I guarantee you'll regret it.

But if you start with an intelligent architecture, so you're not just
replacing lots of Java calls to trivial code with JNI calls to trivial
code, you will usually be OK.

Chris Pruett's strategy as he outlined it in this talk:
http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAndroid.html

I find to be a very solid strategy.

BTW, the argument against moving things *unnecessarily* to JNI is not
just one of performance. It is also negatively affects how quickly you
can modify the code, how well you can test it, and how many bugs
you'll ship with.

But so will doing weird things in Java to try to get it fast enough.
There's a point where it makes sense to move a body of code to JNI.
It's somewhere after you benchmark and think about the problem for a
bit, and before you drive yourself nuts or fail to get your product to
market.

If you've done that, and choose a reasonably cohesive chunk, than in
most cases I wouldn't expect the JNI overhead to be an issue. If it
is, well, you ARE analyzing your trace data, right? You'll figure it
out, and what to do about it.

Just never do "performance optimization" blindly.

On Mar 17, 8:31 am, niko20 <nikolatesl...@yahoo.com> wrote:
> Personally through  my experience this "JNI layer overhead" is so
> small that its effect is negligible. In my apps using NDK with JNI has
> alway increased my speed immensly regardless of any JNI method call
> overhead. It's just simply not true that the JNI will slow you down.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to