iOS and macOS Performance Tuning: Cocoa, Cocoa Touch, Objective-C, and Swift
©2017 |Addison-Wesley Professional | Available
©2017 |Addison-Wesley Professional | Available
In iOS and macOS™ Performance Tuning, Marcel Weiher drills down to the code level to help you systematically optimize CPU, memory, I/O, graphics, and program responsiveness in any Objective-C, Cocoa, or CocoaTouch program.
This guide focuses entirely on performance optimization for macOS and iOS. Drawing on more than 25 years of experience optimizing Apple device software, Weiher identifies concrete performance problems that can be discovered empirically via measurement. Then, based on a deep understanding of fundamental principles, he presents specific techniques for solving them.
Weiher presents insights you won’t find anywhere else, most of them applying to both macOS and iOS development. Throughout, he reveals common pitfalls and misconceptions about Apple device performance, explains the realities, and helps you reflect those realities in code that performs beautifully.
This book’s source code can be downloaded at github.com/mpw/iOS-macOS-performance.
Register your product at informit.com/register for convenient access to downloads, updates, and corrections as they become available.
This product is part of the following series. Click on a series title to see the full list of products in the series.
About the Author xv
Chapter 1: CPU: Principles 1
A Simple Example 2
The Power of Hybrids 10
Cost of Operations 12
Computational Complexity 14
Chapter 2: CPU: Measurement and Tools 17
Command-Line Tools 18
Xcode Gauges 22
Internal Measurement 35
Optimization Beyond the Call of Duty 38
Chapter 3: CPU: Pitfalls and Techniques 41
Mature Optimization 75
Chapter 4: CPU Example: XML Parsing 79
An HTML Scanner 80
Mapping Callbacks to Messages 83
Objects, Cheaply 87
Optimizing the Whole Widget: MAX 94
MAX Implementation 96
Chapter 5: Memory: Principles 99
The Memory Hierarchy 99
Mach Virtual Memory 105
Heap and Stack 106
Resource Management 113
Chapter 6: Memory: Measurement and Tools 119
Xcode Gauges 119
Command-Line Tools 120
Internal Measurement 125
Memory Instruments 126
Chapter 7: Memory: Pitfalls and Techniques 137
Reference Counting 137
Foundation Objects vs. Primitives 141
Smaller Structures 142
Memory and Concurrency 146
Architectural Considerations 147
Temporary Allocations and Object Caching 151
NSCache and libcache 153
Memory-Mapped Files 153
iOS Considerations 157
Optimizing ARC 157
Chapter 8: Memory Example: FilterStreams 161
Unix Pipes and Filters 161
Object-Oriented Filters 163
Stream Hierarchy 170
Chapter 9: Swift 173
Swift Performance: Claims 173
Assessing Swift Performance 177
Larger Examples 188
Compile Times 191
Optimizer-Oriented Programming 195
A Sufficiently Smart Compiler 197
Chapter 10: I/O: Principles 205
Operating System 208
Chapter 11: I/O: Measurement and Tools 215
Negative Space: top and time 216
Summary Information: iostat and netstat 217
Detailed Tracing: fs_usage 221
Chapter 12: I/O: Pitfalls and Techniques 225
Pushing Bytes with NSData 225
Unixy I/O 230
Network I/O 232
Event Posting 264
Segregated Stores 265
Chapter 13: I/O: Examples 267
iPhone Game Dictionary 267
Fun with Property Lists 271
Comma-Separated Values 282
Public Transport Schedule Data 283
Faster CSV Parsing 288
Chapter 14: Graphics and UI: Principles 295
Software and APIs 296
Quartz and the PostScript Imaging Model 299
Graphics Hardware and Acceleration 301
From Quartz Extreme to Core Animation 305
Chapter 15: Graphics and UI: Measurement and Tools 309
CPU Profiling with Instruments 310
Quartz Debug 311
Core Animation Instrument 312
What Am I Measuring? 318
Chapter 16: Graphics and UI: Pitfalls and Techniques 325
Too Much Communication Slows Down Installation 327
Overwhelming an iPhone 330
It’s Just an Illusion 332
Line Drawing on iPhone 338
Chapter 17: Graphics and UI: Examples 343
Beautiful Weather App 343
Wunderlist 3 350
Pearson offers affordable and accessible purchase options to meet the needs of your students. Connect with us to learn more.
K12 Educators: Contact your Savvas Learning Company Account General Manager for purchase options. Instant Access ISBNs are for individuals purchasing with credit cards or PayPal.
Savvas Learning Company is a trademark of Savvas Learning Company LLC.
is a software engineeer and researcher with more than 25 years of experience with Cocoa-related technologies. Marcel’s work has always been performance-focused, ranging from solving impossible pre-press problems on the machines of the day via optimizing one of the world’s busiest web properties at the BBC to helping other Apple engineers improve the performance of their code on Apple’s Mac OS X performance team.
In addition to helping established companies and startups create award-winning software and turn around development teams, Marcel also teaches, blogs, speaks at conferences, contributes to open source, and invents new techniques such as Higher Order Messaging. He also works on programming languages, starting with an Objective-C implementation in 1987 and culminating in the Objective-Smalltalk architecture research language. Marcel currently works as a principal software engineer at Microsoft Berlin and maintains his own software and consulting company, metaobject ltd.
We're sorry! We don't recognize your username or password. Please try again.
The work is protected by local and international copyright laws and is provided solely for the use of instructors in teaching their courses and assessing student learning.
You have successfully signed out and will be required to sign back in should you need to download more resources.