Improving Performance android
Improving Performance android
Improving Performance
Abstract- Android has been researched in various mobile device The structure of the paper is as follows : Section II
fields such as Smartphone and Tablet PC. In here, we should introduces the architecture of Android, JNI and NDK. Section
remember that mobile devices have limited storage and III describes the implementation of the applications for
constrained battery life. Therefore, when developers develop performance measurement in detail. Section IV analyze the
applications, they should do efficient programming. In this measurement results. Section V gives the conclusion.
paper, we have proposed programming guidelines for an effective
way to improve performance in Android applications. We have
programmed Android applications using Java and Native C, and
II. BACKGROUND
Application
--I Exceptions
Applications include five different algorithms (JNI delay,
Integer & Floating-point calculation, Memory access, String
-I
�--------,
N Classes
first one is the JNI delay. JNI delay occurs when a native
__
L--__--'
method is called. Therefore, JNI delay is measured before all
Libraries 1-- I other experiments[8]. Second, we measured the integer
L-___--'
- IL _ _v_M
__-,
calculation time using Fibonacci sequence that consists of only
integer arithmetic. Recalculated after initializing if an Integer
gets out of range. Third, we measured the execution time of
Floating-point processing using the circle area calculation
Figure 2. Architecture of JNI(Java .. C, C++). algorithm that returns the area of a circle whose radius is r. In
the fourth experiment, the memory access time is measured by
using the worst-case scenario of bubble sort. Finally, we
III. EXPERIMENTS measured the time of String processing. It measures the
processing speed of the String by the continuous String input.
In this paper, experimental equipment for performance We used 'nanoTimeO' method in Java (Since JDKI.5) for
evaluation is as follows: Intel Core i5 760 2.8GHz and 3.0GB more accurate measurements. It returns the current value of the
memory. In addition, the experiment was performed on an most precise available system timer, in nanoseconds. This
Android virtual emulator. The emulator target version is method also can only be used to measure elapsed time and is
Android 2.3(API level 9/Gingerbread), and native method was not related to any other notion of system or wall-clock time.
designed using the NDK R5b. The value returned represents nanoseconds since some fixed
but arbitrary time. In other words, This method provides First, JNI delay is about 1. 14 microseconds. It is a slight
nanosecond precision, but not necessarily nanosecond delay, and it does not greatly differ from no-operation delay.
accuracy[9]. In this application, the source code for execution "Fig. 5" shows the results of the Integer & Floating-point
time measurement is shown below. execution time.
o
long estimatedTime = endTime - startTime; � 15 +---------------+-+---��- ""*"Floating point(pi) java
10+-------------����----- -+-Floating point(p� ndk
<Il
The x-axis and the y-axis of the graph represent loop counts
and execution time in milliseconds, respectively. We can see
that Integer arithmetic is faster than Floating-point operations.
Besides, the Native C code is faster than Java code. It means
that we can achieve better performance if we use the Native C
when we design application included many Floating-point
operation such as game and graphic processing.
3� +-------�P_
s: 250000 +-------+--
�. 2� +----+-
g
()
150000 +-------/--- --Memory access java
a...
Figure 4. Performance evaluation. --Memory access ndk
� 1� +----�r-
50000 +----�--=_
IV. RESULIS AND ANALYSIS
All of the above experimental result was calculated using ",<§> f><§> "'<§>� ,\",<§> # # #'
"" '); "i
the harmonic mean. The harmonic mean is one form of Loop counts
average, which is appropriate for situations when the average
Figure 6. Memory access time.
of rates is desired[lO). The harmonic mean H of the real
numbers xl, x2, ... , xn > 0 is defined as follows.
The "Fig. 6" shows the measurement results of memory
access time. "Fig. 6" also shows that Native C is faster than the
Java. In addition, the deviation between Native C and Java
becomes greater(X 9.2) as the number of memory accesses
increase. It means that using Native C is more efficient in case
( 1) of an application where memory access occurs frequently.
It is also more apparent that the harmonic mean is related to String processing measurement results are shown in "Fig.
the arithmetic and geometric means. In this paper, the average 7". In contrast to the above results, the performance of the Java
processing time of each algorithm was calculated using the string processing code is better than that of Native C code. This
above formula (n=lOO) for more accurate measurements. is reason that Java, CIC++ language and IN! String processing
type are different each other. (Java : Unicode, CIC++ : KSC
560 1, JNI : UTF-8) So, type conversion is needed. Therefore, operations. Especially, Native C shows the best performance in
Java language is more efficient when design an Android the memory access operation. On the other hand, Java language
application which included many String processing. is more efficient when design an Android application that
includes many String processing because Java language does
String test(Java vs Native C) not require type conversion of strings.
120
100
REFERENCES
!S:
80
'" [I] Chia-Chi Teng, Richard Helps, "Mobile Application Development :
ro
(1 Essential New Directions for IT", School of Technology, Brigham
0 60
:::J String java Young University, April, 2010.
0..
'"
-t- ---1'-- -- String ndk [2] Stephen D. Drake, "Embracing Next-Generation Mobile Platforms to
40
_
____________
20
[3] Android(Operating System)
http://en.wikipedia.orglwiki/Android_(operating_system).
0 [4] OHA(Open Handset Alliance) http://www.openhandsetalliance.coml.
25 50 75 100 200 3 00 400 500 [5] Official Android developers website http://developer.android.com.
Loop counts [6] Sheng Liang. The Java Native Interface : Programmer's Guide and
Specification, Addison-Wesley, 1999.