I have a project written in Java and I integrated it into an Android app (written in Java as well).
When I measured the execution time for the same method (which refers to several external libraries in the form of .jar files) on both PC and Android, I found that it runs faster on Android. The execution time was measured using the System.currentTimeMillis()
method and The system configurations are as follows:
- PC: Eclipse on a MacBook Air 2017 (Core i5+8GB RAM)
- Android: native app on a Google Pixel 3XL (Snapdragon 845+4GB RAM)
It seems to me that the PC is superior in performance (although it is difficult to compare), so I find it strange that the execution time is shorter on Android.
However, after some research I also found that Java execution on Android is different from that on a PC: Java on Android runs on the Google Android Runtime (ART) and Java on PC runs on the Oracle JVM. Especially, the fact that Android adopts ahead-of-time (AOT) compilation seems to be advantageous to running methods that use .jar libraries on Android. In fact, taking a look at the breakdown of the execution time the time taken to execute codes that invoke jar libraries was much shorter than that on a PC.
So my question is, can such things happen? Can I simply attribute the result to the difference in runtimes and architectures and so on, or am I missing something to be taken into account? Can anyone shed a new light on this?