Search code examples
androidperformanceandroid-ndkjitdalvik

What is the acutal speedup in 4x4 matrix multiplacation in native vs interpreted code on Android?


I am curious of the Dalvik performace when it cames to multiplying 4x4 floating point matrices compared to doing that natively. I will test this myself when I understand how to work with the NDK (I am just starting android through java) but if I know in advance there isn't any big diference I won't waste any time with the NDK.

Has anyone tested this? Does the JIT hide the performance difference well? Is it worth bothering with the NDK for a creating a game? (I am sure this depends on the complexity of the game, but I would like to know when exactly would you consider NDK) Thanks


Solution

  • Has anyone tested this?

    Sorry I haven't ..

    "Does the JIT hide the performance difference well?

    Since android version 2.2 (froyo), runtime dynamic bytecode to native translation was introduced (also known as JIT in the java world).This affects the performance of your compute intensive code path if it is run multiple times (it is a "hot spot"). The implemented JIT in Dalvik is trace based and it is said to have on an average 2 to 5 times the performance on a typical app.With JIT there will be major improvements but i cannot tell you exactly , I presume the performance should be in pair with native code in your example (or even better if you were to use a NDK bridge to native for small computations ). There is a Google IO talk about Dalvik JIT introduced in android 2.2 which might help you here: https://www.youtube.com/watch?v=Ls0tM-c4Vfo

    Is it worth bothering with the NDK for a creating a game?

    It highly depends on the type of game and it's requirements. Maybe you can ask this question as a separate question giving more details relevant to the performance aspect.