Muutke küpsiste eelistusi

iOS and macOS Performance Tuning: Cocoa, Cocoa Touch, Objective-C, and Swift [Pehme köide]

  • Formaat: Paperback / softback, 400 pages, kõrgus x laius x paksus: 226x178x22 mm, kaal: 640 g
  • Sari: Developer's Library
  • Ilmumisaeg: 27-Mar-2017
  • Kirjastus: Addison-Wesley Educational Publishers Inc
  • ISBN-10: 0321842847
  • ISBN-13: 9780321842848
  • Formaat: Paperback / softback, 400 pages, kõrgus x laius x paksus: 226x178x22 mm, kaal: 640 g
  • Sari: Developer's Library
  • Ilmumisaeg: 27-Mar-2017
  • Kirjastus: Addison-Wesley Educational Publishers Inc
  • ISBN-10: 0321842847
  • ISBN-13: 9780321842848
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 wont 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.





Understand optimization principles, measurement, tools, pitfalls, and techniques Recognize when to carefully optimize, and when it isnt worth your time Balance performance and encapsulation to create efficient object representations, communication, data access, and computation Avoid mistakes that slow down Objective-C programs and hinder later optimization Fix leaks and other problems with memory and resource management Address I/O issues associated with drives, networking, serialization, and SQLite Code graphics and UIs that dont overwhelm limited iOS device resources Learn what all developers need to know about Swift performance

This books 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.
About the Author xv
Introduction xvii
1 CPU: Principles
1(16)
A Simple Example
2(8)
The Perils of (Micro-)Benchmarking
3(2)
More Integer Summing
5(1)
Swift
6(1)
Other Languages
7(3)
The Power of Hybrids
10(1)
Trends
11(1)
Cost of Operations
12(2)
Computational Complexity
14(2)
Summary
16(1)
2 CPU: Measurement and Tools
17(24)
Command-Line Tools
18(4)
top
18(1)
time
19(1)
sample
20(2)
Xcode Gauges
22(1)
Instruments
22(13)
Setup and Data Gathering
23(2)
Profiling Options
25(2)
Basic Analysis
27(2)
Source Code
29(3)
Data Mining I Focus
32(2)
Data Mining II Pruning
34(1)
Internal Measurement
35(3)
Testing
37(1)
Dtrace
38(1)
Optimization Beyond the Call of Duty
38(1)
Summary
39(2)
3 CPU: Pitfalls and Techniques
41(38)
Representation
41(7)
Primitive Types
42(3)
Strings
45(3)
Objects
48(16)
Accessors
48(4)
Public Access
52(1)
Object Creation and Caching
52(1)
Mutability and Caching
53(2)
Lazy Evaluation
55(1)
Caching Caveats
56(2)
Pitfall: Generic (Intermediate) Representations
58(1)
Arrays and Bulk Processing
59(2)
Dictionaries
61(3)
Messaging
64(7)
IMP Caching
66(3)
Forwarding
69(2)
Uniformity and Optimization
71(1)
Methods
71(1)
Pitfall: CoreFoundation
71(1)
Multicore
72(3)
Threads
73(1)
Work Queues
74(1)
Mature Optimization
75(4)
4 CPU Example: XML Parsing
79(20)
An HTML Scanner
80(3)
Mapping Callbacks to Messages
83(2)
Objects
85(2)
Objects, Cheaply
87(3)
Evaluation
90(3)
Tune-Ups
93(1)
Optimizing the Whole Widget: MAX
94(2)
MAX Implementation
96(1)
Summary
97(2)
5 Memory: Principles
99(20)
The Memory Hierarchy
99(6)
Mach Virtual Memory
105(1)
Heap and Stack
106(7)
Stack Allocation
108(2)
Heap Allocation with malloc()
110(3)
Resource Management
113(4)
Garbage Collection
114(1)
Foundation Object Ownership
114(1)
Tracing GC
115(1)
Automatic Reference Counting
116(1)
Process-Level Resource Reclamation
117(1)
Summary
117(2)
6 Memory: Measurement and Tools
119(18)
Xcode Gauges
119(1)
Command-Line Tools
120(5)
top
120(1)
heap
121(3)
Leaks and malloc_debug
124(1)
Internal Measurement
125(1)
Memory Instruments
126(10)
Leaks Instrument
126(1)
Allocations
127(7)
VM Tracker
134(1)
Counters/PM Events
134(2)
Summary
136(1)
7 Memory: Pitfalls and Techniques
137(24)
Reference Counting
137(4)
Avoiding Leaks
139(2)
Foundation Objects vs. Primitives
141(1)
Smaller Structures
142(4)
But What About Y2K?
144(1)
Compression
145(1)
Purgeable Memory
145(1)
Memory and Concurrency
146(1)
Architectural Considerations
147(4)
Temporary Allocations and Object Caching
151(2)
NSCache and libcache
153(1)
Memory-Mapped Files
153(3)
Madvise
156(1)
iOS Considerations
157(1)
Optimizing ARC
157(3)
Summary
160(1)
8 Memory Example: FilterStreams
161(12)
Unix Pipes and Filters
161(2)
Object-Oriented Filters
163(1)
DescriptionStream
164(6)
Eliminating the Infinite Recursion from description
168(2)
Stream Hierarchy
170(1)
Summary
171(2)
9 Swift
173(32)
Swift Performance: Claims
173(4)
Language Characteristics
175(2)
Benchmarks
177(1)
Assessing Swift Performance
177(11)
Basic Performance Characteristics
177(2)
Collections
179(9)
Larger Examples
188(3)
nginx HTTP Parser
188(1)
Freddy JSON Parser
189(1)
Image Processing
189(1)
Observations
190(1)
Compile Times
191(4)
Type Inference
191(2)
Generics Specialization
193(1)
Whole-Module Optimization
194(1)
Controlling Compile Times
195(1)
Optimizer-Oriented Programming
195(2)
A Sufficiently Smart Compiler
197(7)
The Death of Optimizing Compilers
199(2)
Practical Advice
201(1)
Alternatives
201(3)
Summary
204(1)
10 I/O: Principles
205(10)
Hardware
205(3)
Disk Drives
205(2)
Solid-State Disks
207(1)
Network
208(1)
Operating System
208(6)
Abstraction: Byte Streams
208(2)
File I/O
210(3)
The Network Stack
213(1)
Summary
214(1)
11 I/O: Measurement and Tools
215(10)
Negative Space: top and time
216(1)
Summary Information: iostat and netstat
217(1)
Instruments
218(3)
Detailed Tracing: fs_usage
221(3)
Summary
224(1)
12 I/O: Pitfalls and Techniques
225(42)
Pushing Bytes with NSData
225(5)
A Memory-Mapping Anomaly
226(2)
How Chunky?
228(2)
Unixy I/O
230(2)
Network I/O
232(10)
Overlapping Transfers
233(1)
Throttling Requests
234(2)
Data Handling
236(1)
Asynchronous I/O
237(1)
HTTP Serving
238(4)
Serialization
242(11)
Memory Dumps
244(1)
A Simple XML Format
244(2)
Property Lists
246(3)
Archiving
249(3)
Serialization Summary
252(1)
CoreData
253(8)
Create and Update in Batches
254(2)
Fetch and Fault Techniques
256(4)
Object Interaction
260(1)
Subsetting
260(1)
Analysis
261(1)
SQLite
261(3)
Relational and Other Databases
263(1)
Event Posting
264(1)
Hybrid Forms
264(1)
Segregated Stores
265(1)
Summary
266(1)
13 I/O: Examples
267(28)
iPhone Game Dictionary
267(4)
Fun with Property Lists
271(11)
A Binary Property List Reader
271(5)
Lazy Reading
276(3)
Avoiding Intermediate Representations
279(3)
Comma-Separated Values
282(1)
Public Transport Schedule Data
283(5)
Stop Time Lookup
285(1)
Stop Time Import
286(2)
Faster CSV Parsing
288(5)
Object Allocation
288(1)
Push vs. Pull
289(1)
Keys of Interest
290(1)
Parallelization
290(3)
Summary
293(2)
14 Graphics and UI: Principles
295(14)
Responsiveness
295(1)
Software and APIs
296(3)
Quartz and the PostScript Imaging Model
299(1)
OpenGL
300(1)
Metal
301(1)
Graphics Hardware and Acceleration
301(4)
From Quartz Extreme to Core Animation
305(3)
Summary
308(1)
15 Graphics and UI: Measurement and Tools
309(16)
CPU Profiling with Instruments
310(1)
Quartz Debug
311(1)
Core Animation Instrument
312(6)
When the CPU Is Not the Problem
314(4)
What Am I Measuring?
318(5)
Summary
323(2)
16 Graphics and UI: Pitfalls and Techniques
325(18)
Pitfalls
325(1)
Techniques
326(1)
Too Much Communication Slows Down Installation
327(3)
The Display Throttle
327(2)
Working with the Display Throttle
329(1)
Installers and Progress Reporting Today
329(1)
Overwhelming an iPhone
330(2)
It's Just an Illusion
332(6)
Image Scaling and Cropping
333(2)
Thumbnail Drawing
335(1)
How Definitely Not to Draw Thumbnails
335(1)
How to Not Really Draw Thumbnails
336(1)
How to Draw Non-Thumbnails
337(1)
Line Drawing on iPhone
338(3)
Summary
341(2)
17 Graphics and UI: Examples
343(16)
Beautiful Weather App
343(7)
An Update
343(1)
Fun with PNG
344(1)
Brainstorming
345(2)
Data Points to JPEG
347(1)
A Measuring Hiccup
347(2)
JPNG and JPJP
349(1)
A Beautiful Launch
350(1)
Wunderlist 3
350(7)
Wunderlist 2
350(1)
Overall Architecture
351(1)
URIs and In-Process REST
352(1)
An Eventually Consistent Asynchronous Data Source
353(1)
RESTOperation Queues
354(1)
A Smooth and Responsive UI
355(2)
Wunderlist in Short
357(1)
Summary
357(2)
Index 359
Marcel Weiher is a software engineeer and researcher with more than 25 years of experience with Cocoa-related technologies. Marcels work has always been performance-focused, ranging from solving impossible pre-press problems on the machines of the day via optimizing one of the worlds busiest web properties at the BBC to helping other Apple engineers improve the performance of their code on Apples 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.