Android Native Development Kit (NDK), 33, 73
Android devices and architectures, 35
Application Binary Interfaces, 35
C extensions, 98
built-in functions, 99
C/C++, performance improvements, 53
Dalvik bytecode, 54
Fibonacci.computeIterativelyFaster() method, 53
iterativeFaster() implementations, 56–57
JNI glue layer (see JNI glue layer)
color conversion, 79
Android.mk, 82
ARMv5 Assembly code (ARM Mode), 80
ARMv5 Assembly code (Thumb Mode), 80
ARMv7 Assembly code (ARM Mode), 80
ARMv7 Assembly code (Thumb Mode), 81
function implementation, 79
Hand-crafted Assembly code, 81
x86 Assembly code, 80
components, 34
directories, 34
greatest common divisor, 74
Android.mk, 78
disassembled gcd_asm code, 79
function implementation, 75
Hand-crafted Assembly code, 78
x86 Assembly code, 75
inlining functions, 104
MIPS technologies, 36
mixing java and C/C++ code, 37
JNI glue layer implementation (see JNI glue layer)
Makefiles (see Makefiles)
native function implementation, 41–43
native method declaration, 37
NativeActivity class, 62
Android.mk, 64
manifest files, 63
new revisions, 36
parallel average function
Android.mk, 86
ARMv5 Assembly code (ARM mode), 83
ARMv5 Assembly code (Thumb mode), 84
ARMv7 Assembly code (ARM mode), 83
ARMv7 Assembly code (Thumb mode), 84, 85
Assembly code mixed with C code, 86
faster implementation, 84
function implementation, 83
Hand-crafted Assembly code, 85
x86 Assembly code, 83
README text file, 34
unrolling loops, 104
Android.mk, basic version, 40
Android.mk file
LOCAL_ARM_MODE, 52
LOCAL_ARM_NEON, 52
LOCAL_CFLAGS and LOCAL_CPPFLAGS, 52
LOCAL_DISABLE_NO_EXECUTE, 52
modules, 53
Application Binary Interfaces (ABIs), 35
Application Not Responding (ANR) dialog, 21
Application.mk
armeabi ABI, 40
basic version, 40
Application.mk file
APP_ABI, 46
APP_CFLAGS and APP_CPPFLAGS, 45
APP_OPTIM, 45
Java implementation
library files, 48
using strategy pattern, 49
libfibonacci.so, 47
MIPS-based Android system, 48
primary and secondary ABIs, 47
variables, 44
ARM Embedded Application Binary Interface, 35
armeabi, 35
Battery life, 177
alarms, 201
ELAPSED_TIME_WAKEUP, 202
RTC and ELAPSED_TIME, 202
RTC_WAKEUP, 202
service implementation, 201–202
broadcast receiver
ACTION_BATTERY_CHANGED, 183
BatteryReceiver implementation, 184
broadcast intents, 183
declaration, 184
enabling and disabling, 186–187
registerReceiver(), 183
Toast messages, 185
G1Phone power consumption, 190
location updates, 191
flaws, 192
GPS location updates, 192
location providers, 192, 194–196
network location updates, 192
unregister a listener, 193
network information
active connection, 187
background data setting, 188–189
data connections, 187
usage
screen and Wi-Fi, 179
WakeLocks
flags, 204
WakeLock creation, 204
Benchmarking and profiling, 163
measuring time
applications, 163
Debug.threadCpuTimeNanos(), 165, 166
System.currentTimeMillis(), 164
tracing, 167
Debug.startMethodTracing() method, 167
BigInteger Version
computeIterativelyFaster, 7
Faster Recursive implementation, 8–11
Fibonacci Q-matrix, 8
lackluster performance, 7
Dalvik bytecode, 2
Dalvik Just-In-Time (JIT) compiler, 33
Dalvik virtual machine, 3
Debug.startMethodTracing() method, 167
Debug.threadCpuTimeNanos(), 165, 166
Fibonacci series
BigInteger version (see BigInteger version)
definition, 2
faster recursive implementation
using BigInteger, 8
using BigInteger and long Primitive Type, 9
using BigInteger and Precomputed results, 10
using BigInteger, long Primitive Type and Cache, 11
human-readable Dalvik bytecode, 2
Naïve recursive Implementation, 2
optimization
iterative implementation, 5
modified iterative implementation, 5–6
recursive implementation, 8–11
Fibonacci.computeIterativelyFaster() method, 53
Garbage collector
GC_CONCURRENT, 130
GC_EXPLICIT, 130
GC_EXTERNAL_ALLOC, 130
GC_FOR_MALLOC, 130
GC_HPROF_DUMP_HEAP, 130
log messages, 130
memory leaks
DDMS perspective, 125
references
soft and weak references, 128
GPS location provider, 194
Graphics, 207
culling, 229
layout tools, 217
Multiple APKs, 228
OpenGL ES, 218
texture compression (see Textures, OpenGL ES)
optimizing layouts
default layout, 208
power consumption, 230
render mode, 229
scene complexity, 229
shaders, 228
Greatest common divisor (gcd), 74
Android.mk, 78
ARMv5 Assembly code
ARM Mode, 76
Thumb Mode, 77
ARMv7 Assembly code
ARM Mode, 76
Thumb Mode, 77
disassembled gcd_asm code, 79
function implementation, 75
Hand-crafted Assembly code, 78
x86 Assembly code, 75
Hierarchy Viewer, 218
Java code optimization, 1
data structures, 17
in java.util package, 18
using LruCache, 18
OutOfMemoryError exception, 19
execution, 2
Dalvik bytecode, 2
dexdump tool, 2
Fibonacci series, 2
Google benchmarks, 3
JIT compiler, 3
virtual register, 3
vmSafeMode, 4
responsiveness, 20
classes, 20
main thread, 20
startup sequence, 21
SQLite, 25
using cache, 11
android.util.LruCache<K, V>, 12–13
Faster Recursive Implementation, 11
HashMap, 11
SparseArray, 11
Java Virtual Machine (VM), 2
java.math package, 6
JNI glue layer, 57
access fields and methods, 59–62
C Source file, 39
Java Development Kit, 38
JNIEnv object, 39
Just-In-Time (JIT) compiler, 3, 33
Layoutopt, 218
Loopers, 142
Low-Level Virtual Machine (LLVM), 233
Makefiles
Android.mk (see Android.mk)
Application.mk (see Application.mk)
LOCAL_MODULE, 41
my-dir macro, 40
ndk-build tool, 40
shared library, 41
Memory management, 109
APIs, 131
data types
add two 64-bit integers, 111
add_16_16 with two 32-bit values, 113
add_16_16's C and assembly, 111
add_16_32's C and assembly, 111
cache miss, 119
Level 1 and 2 cache, 119
sorting, finding and summing, 115–116
sum of two 32-bit values, 111
garbage collection, 125
GC_CONCURRENT, 130
GC_EXPLICIT, 130
GC_EXTERNAL_ALLOC, 130
GC_FOR_MALLOC, 130
GC_HPROF_DUMP_HEAP, 130
log messages, 130
getMemoryInfo() methods, 131
Java primitive types, 110
modified MyRecords class
using short array, 123
modified sum values(), 122
onLowMemory(), 131
performance, 110
physical memory, 109
Record class, 121
virtual memory swapping, 109
Multithreading and synchronization, 133
activity's lifecycle
computation, progression, 158–161
Fibonacci Number computation, 154, 155
AsyncTask, 137
multiple file downloading, 138
protected methods, 138
sequence implementation, 137, 138
UI thread and execution, 139
concurrency, 147
data types
synchronized keywords, 143, 144
Synchronized Statements, 146
volatile keyword addition, 145
loopers, 142
multicore
algorithm modification, 149–152
threads
code execution, 134
creation, 134
Fibonacci number computation, 135
non-UI thread, 135
Native code, 35
NEON registers, 96
Network location provider, 194
Passive location provider, 195
RenderScript, 231
Balls sample application, 231
Hello rendering, 236
Content View setting, 239, 240
RenderScriptGL context creation, 238
RSSurfaceView, 239
script creation, 237
Hello, World script, 233
calling function, 235
LLVM Assembly Language, 236
HelloCompute
RenderScript mono.rs, 243
root() function, 244
LLVM bitcode, 233
native code, 233
native RenderScript APIs
rs_atomic.rsh, 262
vs. NDK, 263
variable addition
alpha component, 242
background Color, 240
blue variable, 242
get() method, 243
global red and green variable, 242
ScriptC_hellorendering2.java, 241, 242
YouTube Carousel view, 231
SQLite
SQLite statements
cheese database, 26
compilation, 27
execution, 25
populateWithCompileStatement, 28
StringBuilder/String format version, 26
transactions, 28
Atomic commit, 28
performance, 29
Textures, OpenGL ES, 221
ARM Mali GPU Compression tool, 223, 224
compression formats, 221
ETC1 compression format, 222
ETC1 compression vs. original image, 222
etcpack tool, 222
Imagination Technologies, 224
PowerVR, 225
uncompressed textures, 221
Virtual register, 3
18.118.253.55