Android
data caching, 250
ListViews performance, 246–248
programming language, 242
Automatic reference counting (ARC)
coding, 180
qualifiers
autoreleasing, 183
object property, 183
strong reference, 182
unsafe_unretained reference, 183
variable declarations, 183
weak reference, 182
rules, 182
Xcode, 181
Belady's algorithm, 65
Big-O notation
general performance analysis, 93
insertion sort performance, 92
myFirstArray and mySecondArray elements, 90
myFirstCount and mySecondCount variables, 90
Binary tree, 106
insert/delete mechanism, 121
left and right child, 121
node and edge, 120
O(log(n)) performance, 119
sorting algorithms, 116
uses, 119
Bottleneck
file activity instrument, 60, 61
file/network loading test, 60
system usage instrument, 61
C programming
advanced data types
function pointers, 228
memory management mechanism, 226–227
string, 225
struct, 225
benefits and costs, 220
data types and functions, 221–222
C programming, 262
.h and .cpp files, 238
benefits and costs, 220
memory management, 232
MyObject.h and MyObject.m files, 238
pointers, 232
TestC_CPlus, 238
Caching
Belady's algorithm, 65
cache hit, 62
cache invalidation, 64
cache miss, 62
data caching. See Data caching
definition, 62
image storage
application bundle, 76
cache directory, 73
temporary directory, 73
least frequently used algorithm, 70–71
least recently used algorithm, 68, 70
memory caching. See Memory caching
random replacement, 66
retrieval cost, 63
simple time-based algorithm, 67–68
storage cost, 63
UIWebView, 72
Cocoa Touch data structures
hashing, 98
isEqual and Hash methods, 98, 100
NSMutableArray, 95
access, 97
API, 97
array illustration, 96
insert/delete, 96
search, 96
sorting, 97
NSMutableSet
access, 102
insert/delete, 101
khang, 101
search, 101
sorting, 102
Data caching
checking and deleting, 81
Data encapsulation, 83
Data structure and algorithm, 253–254
Big-O notation. See Big-O notation
binary tree, 106, Seealso Binary tree
Cocoa Touch data structures. See Cocoa Touch data structures
graph, 106
breadth-first search algorithm, 128, 130
connected graph, 124
depth-first search algorithm, 125–128
directed graph, 125
path, 124
vertex and edge, 124
weighted graph, 125
intersect method, 89
Count method, 112
Get Object method, 112
Init method, 110
Node and List object, 107
performance analysis, 113
Remove Object method, 113
vs. array, 106
NSLog and NSDate, 89
source coding, 88
Facebook, 41
First In First Out (FIFO) algorithm, 66–67
Hashing, 98
iOS performance optimization
Android and Windows Phone environment, 2
Cocoa Touch Framework, 2
Java development, 2
Mac OS, Xcode, 3
network data transfers, 2
smartphone, 1
Stack Overflow, 2
iPhone, 242
Legacy code
memory leaks
Memory caching
Global Access vs. Strict Access, 82
memory allocations and usage, 82
memory warnings, 82
Memory management
advanced autorelease pool, 191–192
advanced memory issues, 184–185
ARC. See Automatic reference counting (ARC)
instruments
leak instrument, 193
memory warning levels, 195
static analyzer, 193
Zombie, 194
old object ownership policy, 178
UIViewController. SeeUIViewController
Multitasking apps performance
application life cycle events, 214
background execution technique, 211–213
guidelines, 213
iOS 3.2, 198
iOS 4.0, 199
iOS versions, 216
life cycle
application:didEnterBackground method, 200, 201
application:didFinishLaunchingWithOptions method, 199
applicationWillTerminate method, 199
background and suspend states, 201
phone interruption and home button, 202
location notification, 211
location service, 207
continuous background location update mechanism, 210
significant location change mechanism, 209–210
standard location services, 208–209
shared resources, 214
show splash screen, 207
system changes notification, 215–216
user interface update, 214–215
VOIP, 211
Multithreading
asynchronous functions, 172–173
autorelease pool, 153
Core Animation instrument, 140
disadvantages, 152
exception handler, 153
Idle-Time Notifications, 173–174
image loading process, 140
instrument, iPhone, 174
liveness
NSLock solution, 162
push and pop threads, 161
multi-processor system, 138
NSObject, 145
NSOperationQueue, 146
code snippet, 147
NSBlockOperation, 148
NSInvocationOperation, 147
NSThread, 144
NSTimer, 171
odd/even integer code, 156
priorities, 151
run loop, 154
safety
application crash, 157
single-processor system, 138
stacks, 151
thread-local storage, 151
UITableViewDataSource's Method, 141
Old object ownership policy, 178
Performance tools, 18
battery power measurement, 31–32
blank template, 33
CPU measurement
activity monitor, 23
advantages, 22
CPU sampler panel, 21
Hide System Libraries, 21
running count, function call, 22
running time, function call, 22
sample and stack trace, 20
system load and user load, 21
usages, 23
file and network access measurement
file I/O and network access, 19
instrument applications, 19–20
library list, 33
measure thread performance, 30
user interface response time measurement
Simulators and real device test
iPhone simulator environment and real iPhone environment, 8
memory and runtime performance, 8, 9
memory tools
automatic reference counting, 10
convert tool, 10
legacy code. See Legacy code
performance tools. See Performance tools
SlowPerformanceTableView project, 41
Smartphone, 1
Thread-safe, 169
UITableView performance
cell preparation process, 54
custom cell drawing
custom drawing code, 51
drawInRect method, 53
drawRect method, 53
images reusing, 51
source code, 52
TableViewCell, 52
user interface, 50
editing/reordering performance, 56
Facebook, 41
height caching, 54
initial benchmark, 43
NSLog, 40
opaque, 55
preparation time reduction, 49
ReuseIdentifier, 54
SlowPerformanceTableView project, 41
tableView dequeues, 39
UITableViewCell reusing
benchmarks, 47
CPU-intensive process, 43
custom class ReuseTableViewCell, 45
custom code, 46
Nib file, 46
standard TableView Cell, 44
UIViewController
life cycle, 185
viewDidAppear method, 188
viewDidDisappear method, 188
viewWillAppear method, 187
viewWillDisappear method, 188
Voice Over IP (VOIP), 211
Windows phone
automatic binding mechanism, 246
benchmarking, 245
C# programming language, 242
emulator, 243
ListViews performance, 248–249
user interface framework, 242