F
F
flm2011-05-21 15:03:59
Java
flm, 2011-05-21 15:03:59

Android: Java VS C++

I wrote a small application for android, but there is a decent “mathematics” plus work with a bitmap. In Java, the calculation takes a very long time. For comparison, on a desktop (2.5 GHz) the usual C++ version considers the task 3 seconds, on the same java-android desktop in the emulator, the task is considered 2 minutes.

In this regard, a question arises. Does it make sense to pervert with c ++ under android, will there be an increase in the speed of "mathematics", approximately what?
Thank you.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
R
Roman, 2011-05-21
@WNeZRoS

The android emulator is slow, it's better to see the calculation time on the device.

V
vinxru, 2011-05-21
@vinxru

Does your version of Android use a JIT compiler? It seems to have appeared since Android 2.2.
With a JIT compiler, identical programs (as far as languages ​​allow) will run at approximately the same speed.
But on the other hand, perversions in C ++ and inserts in assembler allow you to increase the performance of the program by an order of magnitude (and increase the number of problems for the programmer by an order of magnitude)

M
mt_, 2011-05-21
@mt_

I would write a small and very simple study on which I would look at the real increase in speed in C ++.
If the increase is large enough (everyone determines the measure himself), then he would start writing in C ++.

T
thevery, 2011-05-21
@thevery

There is an increase, how much depends on the specific task: java in android is quite slow, alas.

Y
YoungSkipper, 2011-05-21
@YoungSkipper

See what code you have. By and large, an overhead can be due to working with an array, perhaps, well, or from the bitmap itself.
In pure mathematics, you will not get a significant increase in speed without changing the algorithm.
Plus, do not forget that you need to transfer the layer to jni now - this is also the time.
What takes the most time in your calculations? What function is the bootle neck - bring it, then it will be possible to assess whether there will be a win.

V
vsvasya, 2011-05-21
@vsvasya

Is it possible to write a library in C ++ in android and connect it to a Java project?

G
Ganesh, 2011-05-22
@Ganesh

Try to translate them into a simple toArray() array before working with a list of pixels.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question