SlideShare a Scribd company logo
1 of 25
iOS App Performance 
Things to Take Care 
Gurpreet Singh Sachdeva 
Engineering Manager @ Yahoo
Who should attend this session? 
• If you are developing or planning to develop 
iOS apps and looking for tips to make your 
apps fast then you are right place. 
• Pre-requisite: Basic Objective-C knowledge
Why performance is important? 
• Faster apps provide a better user experience 
• Users expect high performance 
• If your app is slow or unresponsive it is bound 
to get bad reviews and loose user base. 
• Remember, mobile devices have less RAM.
Performance Tips 
• Use ARC 
• In addition to helping you avoid memory leaks, ARC can 
also improve your performance, by making sure that 
objects are de-allocated as soon as they are no longer 
needed. 
• These days, you should always use ARC in your projects!
Performance Tips 
• Don’t block the main thread 
• You should never do any heavy lifting on the main 
thread. Remember, UIKit does all of its work on the 
main thread, such as drawing, managing touches, and 
responding to input. 
• Most cases of blocking the main thread occur when your 
app is performing an I/O operation which involves any 
task that needs to read or write from an external 
source, such as the disk or the network. 
• You can perform network tasks asynchronously by using 
this method on NSURLConnection
Performance Tips 
• Use a reuseIdentifier where appropriate 
• A table view’s data source should generally reuse 
UITableViewCell objects when it assigns cells to rows. 
• Otherwise, table view will configure new cell each time 
a row is displayed. This is an expensive operation and 
will affect the scrolling performance of your app 
• To use reuseIdentifiers, call this method from your data 
source object when asked to provide a new cell for the 
table view: 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Performance Tips 
• Avoid fat XIBs 
• If you are still using XIB files for some reason (may be for 
supporting pre iOS 5 devices) then make them as 
uncomplicated as possible. 
• Note that when you load a XIB into memory, all of its 
contents are loaded into memory, including any images. 
• If you have a view you’re not using immediately, then you’re 
wasting precious memory. 
• It’s worth noting that this won’t happen with storyboards, 
since a storyboard will only instantiate a view controller when 
it’s needed.
Performance Tips 
• Size images to Image Views 
• Scaling images on the fly can be expensive, especially if 
your UIImageView is embedded in a UIScrollView. 
• If the image is downloaded from a remote service, 
sometimes you don’t have control over the size, or you 
might not be able to scale it on the server prior to 
downloading.
Performance Tips 
• Choose the correct Collection 
• Learning to use the most appropriate class or object for 
the task at hand is fundamental to writing efficient 
code. This is especially true when dealing with 
collections. 
• There is a document on Apple’s Developer Library that 
explains in detail the differences between the available 
classes, as well as which situations suit each class. It’s a 
must read document for anyone looking to work with 
collections.
Performance Tips 
• Enable GZIP compression 
• Speed up the download of network-based resources by 
enabling GZIP compression on both your server and on 
your client. 
• The good news is that iOS already supports GZIP 
compression by default if you’re using 
NSURLConnection, or a framework built on top of it such 
as AFNetworking. 
• There is a great article about GZIP compression which 
explains how to enable it on your Apache or IIS server.
Performance Tips 
• Reuse and lazy Load Views 
• Create your views as you need them. 
• More views means more drawing; which ultimately 
means more CPU and memory overhead. This is 
especially true if your app embeds many views inside of 
a UIScrollView.
Performance Tips 
• Cache what matters 
• Cache things that are unlikely to change, but are 
accessed frequently. 
• What can you cache? 
• Some candidates for caching are remote server responses, 
images. 
• NSURLConnection already caches resources on disk or in 
memory according to the HTTP headers it processes.
Performance Tips 
• Handle memory warnings 
• iOS notifies all running apps when system memory is 
running low. 
• UIKit provides several ways to receive these low-memory 
warnings, including the following: 
• Implement the applicationDidReceiveMemoryWarning: method of your 
app delegate. 
• Override didReceiveMemoryWarning in your custom UIViewController 
subclass. 
• Register to receive the 
UIApplicationDidReceiveMemoryWarningNotification notification. 
• Upon receiving any of these warnings, free up any unnecessary 
memory. 
• Purge unused data structures, release any images that are not 
currently on-screen.
Performance Tips 
• Reuse expensive Objects 
• Some objects are very slow to initialize — 
NSDateFormatter and NSCalendar are two examples. 
• To avoid performance bottlenecks when working with 
these objects, try to reuse these objects if at all possible. 
• You can do this by either adding a property to your class or 
using static
Performance Tips 
• Optimize Your Table Views 
• Tips for optimizing Table Views 
• Reuse cells by setting the correct reuseIdentifier. 
• Make as many views opaque as possible, including the cell 
itself. 
• Avoid gradients, image scaling. 
• If the cell shows content that comes from the web, be sure to 
make those calls asynchronously and cache the responses. 
• Reduce the number of subviews. 
• Do as little work as possible in cellForRowAtIndexPath:. If you 
need to do some work, do it only once and cache the results. 
• Use the appropriate data structure to hold the information you 
need. Different structures have different costs for different 
operations.
Performance Tips 
• Speed up launch time 
• Launching your app quickly is very important, especially 
when the user launches for the first time. First 
impressions mean a lot for an app! 
• Ensure your app starts as quickly as possible is to 
perform asynchronous tasks. 
• You need to strike a balance between what to fetch before app 
launch and what to fetch once the app is launched. 
• Try to avoid fat XIBs, since they’re loaded on the main 
thread. But recall that storyboards don’t have this 
problem — so use them if you can!
Performance Tips 
• Cache Images (when?) 
• There are two common ways to load a UIImage from an 
app bundle. 
• Using imageNamed and second using 
imageWithContentsOfFile. 
• imageNamed has the advantage of caching the image as it’s loaded. 
• Alternately, imageWithContentsOfFile simply loads the image with no 
caching. 
• When would you use one over the other? 
• If you’re loading a large image that will be used only once, 
there’s no need to cache the image. 
• However, imageNamed is a much better choice for images that 
you’re going to be reusing in your app.
Performance Tips 
• Reduce battery consumption 
• Optimize use of the following features: 
• The CPU 
• Wi-Fi, Bluetooth, and baseband (EDGE, 3G) radios 
• The Core Location framework 
• The accelerometers 
• The disk 
• Consider the following guidelines: 
• Avoid doing work that requires polling. 
• Avoid accessing the disk too frequently. 
• Do not draw to the screen faster than is needed. 
• Connect to external network servers only when needed, and do 
not poll those servers. 
• Disable location updates as soon as you can.
Performance Tips 
• Reduce App’s memory footprint 
• Actions to take 
• Eliminate memory leaks. 
• Make resource files as small as possible. 
• Use Core Data or SQLite for large data sets. 
• Load resources lazily.
Performance Tips 
• Use NSLog as sparingly as possible in production 
• Messages written using NSLog are presented in the 
debugger console and even to the device's console log 
in production. 
• NSLog() takes a non-negligible amount of time. 
• The following are commonly used log definitions that 
are used to selectively perform NSLog() in 
debug/production: 
#ifdef DEBUG 
// Only log when attached to the debugger 
# define DLog(...) NSLog(__VA_ARGS__) 
#else 
# define DLog(...) /* */ 
#endif 
// Always log, even in production 
#define ALog(...) NSLog(__VA_ARGS__)
Performance Tips 
• Be Lazy 
• Defer memory allocations until you actually need the 
memory. 
• Defer reading the contents of a file until you actually 
need the information.
Performance Tips 
• Take Advantage of Perceived Performance 
• The perception of performance is just as effective as 
actual performance in many cases. 
• Many program tasks can be performed in the 
background, using a dispatch queue, or at idle time. 
• Doing this keeps the application’s main thread free to handle 
user interactions and makes the program interface feel more 
responsive to the user. 
• If your program needs to scan a number of files or perform 
lengthy calculations, do so using a dispatch queue. 
• There is a good document available on apple’s site for 
Concurrency Programing
Analyzing the performance 
• Using apple tools for analyzing performance 
• https 
://developer.apple.com/library/ios/documentation/Performance/ 
Conceptual/PerformanceOverview/PerformanceTools/Performanc 
eTools.html#//apple_ref/doc/uid/TP40001410-CH205-BCIIHAAJ
References 
Marcelo Fabri - 25 iOS App Performance Tips & Tricks. Retrieved from 
http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks
iOS App performance - Things to take care

More Related Content

What's hot

Chrome DevTools로 JS 메모리릭 디버깅하기.pptx
Chrome DevTools로 JS 메모리릭 디버깅하기.pptxChrome DevTools로 JS 메모리릭 디버깅하기.pptx
Chrome DevTools로 JS 메모리릭 디버깅하기.pptxEunsu Kim
 
Python 게임서버 안녕하십니까 : RPC framework 편
Python 게임서버 안녕하십니까 : RPC framework 편Python 게임서버 안녕하십니까 : RPC framework 편
Python 게임서버 안녕하십니까 : RPC framework 편준철 박
 
[NDC16] Effective Git
[NDC16] Effective Git[NDC16] Effective Git
[NDC16] Effective GitChanwoong Kim
 
BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabTaeung Song
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
서버 아키텍쳐 입문
서버 아키텍쳐 입문서버 아키텍쳐 입문
서버 아키텍쳐 입문중선 곽
 
4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴Terry Cho
 
스프링 부트와 로깅
스프링 부트와 로깅스프링 부트와 로깅
스프링 부트와 로깅Keesun Baik
 
[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규
[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규
[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규ChangKyu Song
 
C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현Bongseok Cho
 
Ceph Day Taipei - Accelerate Ceph via SPDK
Ceph Day Taipei - Accelerate Ceph via SPDK Ceph Day Taipei - Accelerate Ceph via SPDK
Ceph Day Taipei - Accelerate Ceph via SPDK Ceph Community
 
Getting Started - Ansible Galaxy NG
Getting Started - Ansible Galaxy NGGetting Started - Ansible Galaxy NG
Getting Started - Ansible Galaxy NGHideki Saito
 
Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008Ryan Chou
 
Massive service basic
Massive service basicMassive service basic
Massive service basicDaeMyung Kang
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with AnsibleIvan Serdyuk
 
Efficient Rendering with DirectX* 12 on Intel® Graphics
Efficient Rendering with DirectX* 12 on Intel® GraphicsEfficient Rendering with DirectX* 12 on Intel® Graphics
Efficient Rendering with DirectX* 12 on Intel® GraphicsGael Hofemeier
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX, Inc.
 
초보자를 위한 Git & GitHub
초보자를 위한 Git & GitHub초보자를 위한 Git & GitHub
초보자를 위한 Git & GitHubYurim Jin
 

What's hot (20)

Chrome DevTools로 JS 메모리릭 디버깅하기.pptx
Chrome DevTools로 JS 메모리릭 디버깅하기.pptxChrome DevTools로 JS 메모리릭 디버깅하기.pptx
Chrome DevTools로 JS 메모리릭 디버깅하기.pptx
 
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
 
Python 게임서버 안녕하십니까 : RPC framework 편
Python 게임서버 안녕하십니까 : RPC framework 편Python 게임서버 안녕하십니까 : RPC framework 편
Python 게임서버 안녕하십니까 : RPC framework 편
 
[NDC16] Effective Git
[NDC16] Effective Git[NDC16] Effective Git
[NDC16] Effective Git
 
BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLab
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
서버 아키텍쳐 입문
서버 아키텍쳐 입문서버 아키텍쳐 입문
서버 아키텍쳐 입문
 
4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴
 
스프링 부트와 로깅
스프링 부트와 로깅스프링 부트와 로깅
스프링 부트와 로깅
 
[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규
[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규
[NDC13] 70명이 커밋하는 라이브 개발하기 (해외 진출 라이브 프로젝트의 개발 관리) - 송창규
 
C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현
 
Ceph Day Taipei - Accelerate Ceph via SPDK
Ceph Day Taipei - Accelerate Ceph via SPDK Ceph Day Taipei - Accelerate Ceph via SPDK
Ceph Day Taipei - Accelerate Ceph via SPDK
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
 
Getting Started - Ansible Galaxy NG
Getting Started - Ansible Galaxy NGGetting Started - Ansible Galaxy NG
Getting Started - Ansible Galaxy NG
 
Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008
 
Massive service basic
Massive service basicMassive service basic
Massive service basic
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Efficient Rendering with DirectX* 12 on Intel® Graphics
Efficient Rendering with DirectX* 12 on Intel® GraphicsEfficient Rendering with DirectX* 12 on Intel® Graphics
Efficient Rendering with DirectX* 12 on Intel® Graphics
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best Practices
 
초보자를 위한 Git & GitHub
초보자를 위한 Git & GitHub초보자를 위한 Git & GitHub
초보자를 위한 Git & GitHub
 

Similar to iOS App performance - Things to take care

Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Jess Coburn
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best PracticesJean-Luc David
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara AnjargolianHakka Labs
 
Google app development
Google app developmentGoogle app development
Google app developmentAurel Medvegy
 
Google app developers
Google app developersGoogle app developers
Google app developersAurel Medvegy
 
Web software development
Web software developmentWeb software development
Web software developmentAurel Medvegy
 
Google app developer
Google app developerGoogle app developer
Google app developerAurel Medvegy
 
Google apps development
Google apps developmentGoogle apps development
Google apps developmentAurel Medvegy
 
Google app engine developer
Google app engine developerGoogle app engine developer
Google app engine developerAurel Medvegy
 
Cloud computing providers
Cloud computing providersCloud computing providers
Cloud computing providersAurel Medvegy
 
Google app programming
Google app programmingGoogle app programming
Google app programmingAurel Medvegy
 
App engine applications
App engine applicationsApp engine applications
App engine applicationsAurel Medvegy
 
Google app engine example apps
Google app engine example appsGoogle app engine example apps
Google app engine example appsAurel Medvegy
 

Similar to iOS App performance - Things to take care (20)

Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best Practices
 
Appengine json
Appengine jsonAppengine json
Appengine json
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Google app development
Google app developmentGoogle app development
Google app development
 
Google app developers
Google app developersGoogle app developers
Google app developers
 
Google development
Google developmentGoogle development
Google development
 
Google app
Google appGoogle app
Google app
 
Web software development
Web software developmentWeb software development
Web software development
 
Google app developer
Google app developerGoogle app developer
Google app developer
 
Google web tools
Google web toolsGoogle web tools
Google web tools
 
Google apps development
Google apps developmentGoogle apps development
Google apps development
 
Google app pricing
Google app pricingGoogle app pricing
Google app pricing
 
Google app engine developer
Google app engine developerGoogle app engine developer
Google app engine developer
 
Cloud computing providers
Cloud computing providersCloud computing providers
Cloud computing providers
 
Google app software
Google app softwareGoogle app software
Google app software
 
Google app programming
Google app programmingGoogle app programming
Google app programming
 
App engine applications
App engine applicationsApp engine applications
App engine applications
 
Google app engine example apps
Google app engine example appsGoogle app engine example apps
Google app engine example apps
 

More from Gurpreet Singh Sachdeva

More from Gurpreet Singh Sachdeva (6)

Firefox addons
Firefox addonsFirefox addons
Firefox addons
 
Introduction to Greasemonkey
Introduction to GreasemonkeyIntroduction to Greasemonkey
Introduction to Greasemonkey
 
iOS training (advanced)
iOS training (advanced)iOS training (advanced)
iOS training (advanced)
 
iOS training (intermediate)
iOS training (intermediate)iOS training (intermediate)
iOS training (intermediate)
 
iOS training (basic)
iOS training (basic)iOS training (basic)
iOS training (basic)
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data Warehousing
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

iOS App performance - Things to take care

  • 1. iOS App Performance Things to Take Care Gurpreet Singh Sachdeva Engineering Manager @ Yahoo
  • 2. Who should attend this session? • If you are developing or planning to develop iOS apps and looking for tips to make your apps fast then you are right place. • Pre-requisite: Basic Objective-C knowledge
  • 3. Why performance is important? • Faster apps provide a better user experience • Users expect high performance • If your app is slow or unresponsive it is bound to get bad reviews and loose user base. • Remember, mobile devices have less RAM.
  • 4. Performance Tips • Use ARC • In addition to helping you avoid memory leaks, ARC can also improve your performance, by making sure that objects are de-allocated as soon as they are no longer needed. • These days, you should always use ARC in your projects!
  • 5. Performance Tips • Don’t block the main thread • You should never do any heavy lifting on the main thread. Remember, UIKit does all of its work on the main thread, such as drawing, managing touches, and responding to input. • Most cases of blocking the main thread occur when your app is performing an I/O operation which involves any task that needs to read or write from an external source, such as the disk or the network. • You can perform network tasks asynchronously by using this method on NSURLConnection
  • 6. Performance Tips • Use a reuseIdentifier where appropriate • A table view’s data source should generally reuse UITableViewCell objects when it assigns cells to rows. • Otherwise, table view will configure new cell each time a row is displayed. This is an expensive operation and will affect the scrolling performance of your app • To use reuseIdentifiers, call this method from your data source object when asked to provide a new cell for the table view: static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  • 7. Performance Tips • Avoid fat XIBs • If you are still using XIB files for some reason (may be for supporting pre iOS 5 devices) then make them as uncomplicated as possible. • Note that when you load a XIB into memory, all of its contents are loaded into memory, including any images. • If you have a view you’re not using immediately, then you’re wasting precious memory. • It’s worth noting that this won’t happen with storyboards, since a storyboard will only instantiate a view controller when it’s needed.
  • 8. Performance Tips • Size images to Image Views • Scaling images on the fly can be expensive, especially if your UIImageView is embedded in a UIScrollView. • If the image is downloaded from a remote service, sometimes you don’t have control over the size, or you might not be able to scale it on the server prior to downloading.
  • 9. Performance Tips • Choose the correct Collection • Learning to use the most appropriate class or object for the task at hand is fundamental to writing efficient code. This is especially true when dealing with collections. • There is a document on Apple’s Developer Library that explains in detail the differences between the available classes, as well as which situations suit each class. It’s a must read document for anyone looking to work with collections.
  • 10. Performance Tips • Enable GZIP compression • Speed up the download of network-based resources by enabling GZIP compression on both your server and on your client. • The good news is that iOS already supports GZIP compression by default if you’re using NSURLConnection, or a framework built on top of it such as AFNetworking. • There is a great article about GZIP compression which explains how to enable it on your Apache or IIS server.
  • 11. Performance Tips • Reuse and lazy Load Views • Create your views as you need them. • More views means more drawing; which ultimately means more CPU and memory overhead. This is especially true if your app embeds many views inside of a UIScrollView.
  • 12. Performance Tips • Cache what matters • Cache things that are unlikely to change, but are accessed frequently. • What can you cache? • Some candidates for caching are remote server responses, images. • NSURLConnection already caches resources on disk or in memory according to the HTTP headers it processes.
  • 13. Performance Tips • Handle memory warnings • iOS notifies all running apps when system memory is running low. • UIKit provides several ways to receive these low-memory warnings, including the following: • Implement the applicationDidReceiveMemoryWarning: method of your app delegate. • Override didReceiveMemoryWarning in your custom UIViewController subclass. • Register to receive the UIApplicationDidReceiveMemoryWarningNotification notification. • Upon receiving any of these warnings, free up any unnecessary memory. • Purge unused data structures, release any images that are not currently on-screen.
  • 14. Performance Tips • Reuse expensive Objects • Some objects are very slow to initialize — NSDateFormatter and NSCalendar are two examples. • To avoid performance bottlenecks when working with these objects, try to reuse these objects if at all possible. • You can do this by either adding a property to your class or using static
  • 15. Performance Tips • Optimize Your Table Views • Tips for optimizing Table Views • Reuse cells by setting the correct reuseIdentifier. • Make as many views opaque as possible, including the cell itself. • Avoid gradients, image scaling. • If the cell shows content that comes from the web, be sure to make those calls asynchronously and cache the responses. • Reduce the number of subviews. • Do as little work as possible in cellForRowAtIndexPath:. If you need to do some work, do it only once and cache the results. • Use the appropriate data structure to hold the information you need. Different structures have different costs for different operations.
  • 16. Performance Tips • Speed up launch time • Launching your app quickly is very important, especially when the user launches for the first time. First impressions mean a lot for an app! • Ensure your app starts as quickly as possible is to perform asynchronous tasks. • You need to strike a balance between what to fetch before app launch and what to fetch once the app is launched. • Try to avoid fat XIBs, since they’re loaded on the main thread. But recall that storyboards don’t have this problem — so use them if you can!
  • 17. Performance Tips • Cache Images (when?) • There are two common ways to load a UIImage from an app bundle. • Using imageNamed and second using imageWithContentsOfFile. • imageNamed has the advantage of caching the image as it’s loaded. • Alternately, imageWithContentsOfFile simply loads the image with no caching. • When would you use one over the other? • If you’re loading a large image that will be used only once, there’s no need to cache the image. • However, imageNamed is a much better choice for images that you’re going to be reusing in your app.
  • 18. Performance Tips • Reduce battery consumption • Optimize use of the following features: • The CPU • Wi-Fi, Bluetooth, and baseband (EDGE, 3G) radios • The Core Location framework • The accelerometers • The disk • Consider the following guidelines: • Avoid doing work that requires polling. • Avoid accessing the disk too frequently. • Do not draw to the screen faster than is needed. • Connect to external network servers only when needed, and do not poll those servers. • Disable location updates as soon as you can.
  • 19. Performance Tips • Reduce App’s memory footprint • Actions to take • Eliminate memory leaks. • Make resource files as small as possible. • Use Core Data or SQLite for large data sets. • Load resources lazily.
  • 20. Performance Tips • Use NSLog as sparingly as possible in production • Messages written using NSLog are presented in the debugger console and even to the device's console log in production. • NSLog() takes a non-negligible amount of time. • The following are commonly used log definitions that are used to selectively perform NSLog() in debug/production: #ifdef DEBUG // Only log when attached to the debugger # define DLog(...) NSLog(__VA_ARGS__) #else # define DLog(...) /* */ #endif // Always log, even in production #define ALog(...) NSLog(__VA_ARGS__)
  • 21. Performance Tips • Be Lazy • Defer memory allocations until you actually need the memory. • Defer reading the contents of a file until you actually need the information.
  • 22. Performance Tips • Take Advantage of Perceived Performance • The perception of performance is just as effective as actual performance in many cases. • Many program tasks can be performed in the background, using a dispatch queue, or at idle time. • Doing this keeps the application’s main thread free to handle user interactions and makes the program interface feel more responsive to the user. • If your program needs to scan a number of files or perform lengthy calculations, do so using a dispatch queue. • There is a good document available on apple’s site for Concurrency Programing
  • 23. Analyzing the performance • Using apple tools for analyzing performance • https ://developer.apple.com/library/ios/documentation/Performance/ Conceptual/PerformanceOverview/PerformanceTools/Performanc eTools.html#//apple_ref/doc/uid/TP40001410-CH205-BCIIHAAJ
  • 24. References Marcelo Fabri - 25 iOS App Performance Tips & Tricks. Retrieved from http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks