0

I'm an iOS developer and I'm considering getting into Android development.

In Objective-C, I'm used to being able to optimize and tune specific hotspots (e.g. image processing) using inline directives and low-level code.

How do I do the same in Android? Is the answer Renderscript? Is Renderscript compatible with all Android devices?

At a minimum, can I specify that certain methods should be inlined to save on procedure calls in extremely, extremely tight loops?

Bill
  • 44,502
  • 24
  • 122
  • 213

1 Answers1

2

How do I do the same in Android?

If by "the same" you mean "using inline directives and low-level code", generally you don't "do the same". There is no "inline directive" in Java. You are welcome to use the NDK to add native code to your Android app.

Is the answer Renderscript?

Renderscript Compute can be used to improve performance of things that Renderscript Compute is good at, and image processing tends to be one (at least for some types of processing, like filters).

Is Renderscript compatible with all Android devices?

AFAIK it should be available on all Android devices running API Level 11 and higher (a.k.a., Android 3.0+).

can I specify that certain methods should be inlined to save on procedure calls in extremely, extremely tight loops?

No. The Dalvik JIT will detect and optimize such code based on its own internal heuristics.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    Renderscript Compute is definitely appropriate if you are looking at parallel workloads (via kernels with forEach). If you have single-threaded code that also requires some level of specialization/optimization, you can also use RS Compute, although it would be via the invoke mechanism. The primary benefit for using RS Compute instead of JNI in these cases is that your application remains fully portable, and does not require multiple compiles/recompiles for different target architectures. – Stephen Hines Dec 11 '12 at 18:07