Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Performance Optimization for iOS Apps
Search
Vitalii Topoliuk
August 14, 2013
Programming
3
86
Performance Optimization for iOS Apps
Tips & Tricks from personal experience.
Vitalii Topoliuk
August 14, 2013
Tweet
Share
More Decks by Vitalii Topoliuk
See All by Vitalii Topoliuk
Responsive UI for iOS Apps
vtopoliuk
5
430
Other Decks in Programming
See All in Programming
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Jakarta EE meets AI
ivargrimstad
0
640
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.8k
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Vapor Revolution
kazupon
1
130
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Outline View in SwiftUI
1024jp
1
340
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
1k
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
React への依存を最小にするフロントエンド設計
takonda
8
2.1k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Building Applications with DynamoDB
mza
90
6.1k
For a Future-Friendly Web
brad_frost
175
9.4k
What's in a price? How to price your products and services
michaelherold
243
12k
A Tale of Four Properties
chriscoyier
156
23k
Optimizing for Happiness
mojombo
376
70k
Six Lessons from altMBA
skipperchong
27
3.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
We Have a Design System, Now What?
morganepeng
50
7.2k
Writing Fast Ruby
sferik
627
61k
Transcript
Performance Optimization Vitalii Topoliuk @vtopoliuk
- Performance scenarios - How to measure performance - How
to improve key scenarios - Tips and Tricks Contents:
- Not just about speed - CPU tasks - Memory
- Rendering - File I/O - Networking - Power Performance Performance scenarios
- Not just about speed - CPU tasks - Memory
- Rendering - File I/O - Networking - Power Performance Performance scenarios
Overall recommendations Performance scenarios - Don’t guess, just measure -
Measure on slowest device - Measure on pessimistic data - Measure on real data
How to measure Performance scenarios - Instruments - Logging -
Quartz Debug (OS X)
CPU Performance Optimization
- Unhappy users CPU CPU Tasks Optimization
- Unhappy users - System can abort your app CPU
CPU Tasks Optimization
Time Profiler Demo CPU Tasks Optimization
CPU Tasks Optimization
CPU Tasks Optimization
- do less work - do work later - do
slow in background and use placeholders - do work faster Main strategies CPU Tasks Optimization
Memory Performance Optimization
- Crashes => Unhappy Users Memory Memory Optimization
Allocations & Leaks Demo Memory Optimization
Memory Optimization
Memory Optimization
Memory Optimization
- do less work - do work later - break
down work to smallest batches - use ARC :) - @autoreleasepool Main strategies Memory Optimization
.nib loading Tips and Tricks x10 faster
ARC vs MMM Tips and Tricks - (void)getPoints:(DPoint[2])outPoint forCenterPoint:(DPoint)centerPoint targetingVector:
(DVector)targetingVector skipEquation:(BOOL)skip lineWidth:(DFloat)lineWidth { DVector normVector = DVectorNormalVector(targetingVector); DFloat originX = centerPoint.x + (lineWidth / 2.0f) * normVector.x; ... // some code outPoint[1] = (DPoint){originX, originY}; }
ARC vs MMM Tips and Tricks x5 faster on MMM
- (void)getPoints:(DPoint[2])outPoint forCenterPoint:(DPoint)centerPoint targetingVector: (DVector)targetingVector skipEquation:(BOOL)skip lineWidth:(DFloat)lineWidth { DVector normVector = DVectorNormalVector(targetingVector); DFloat originX = centerPoint.x + (lineWidth / 2.0f) * normVector.x; ... // some code outPoint[1] = (DPoint){originX, originY}; }
Universal solutions Tips and Tricks [self.array addObject:[NSValue valueWithCGPoint:point]] xxx times
faster VS @interface DPointsCollection : NSObject - (void)addPoint:(CGPoint)point atIndex:(NSUInteger)index; - (void)removePointAtIndex:(NSUInteger)index; ... @end
Sorted NSArray Tips and Tricks [self.array addObject:object]; [self.array sortUsing...];
Sorted NSArray Tips and Tricks NSUInteger index = [self.array indexOfObject:object
inSortedRange:range options:NSBinarySearchingInsertionIndex usingComparator:comparator]; [self.array insertObject:object atIndex:index];
Delay large tasks Tips and Tricks - (void)addPerson:(DPerson*)person { ...
[self save]; // large task } - (void)addBook:(DBook*)book { ... [self save]; // large task }
Delay large tasks Tips and Tricks - (void)addPerson:(DPerson*)person { ...
[self delayedSave]; } - (void)addBook:(DBook*)book { ... [self delayedSave]; } - (void)delayedSave { [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(save) object:nil]; [self performSelector:@selector(save) withObject:nil afterDelay:0.1f]; }
API Levels Tips and Tricks - try high level API
first - then try lower level NSArray => CFArray => void* NSXMLParser => libxml
Questions & Answers Performance Optimization