AutoLayout Performance

38 views
Skip to first unread message

Aaron

unread,
Apr 26, 2013, 11:23:42 AM4/26/13
to CocoaHeads
Keith & I (and a few others) had a good discussion at the last CocoaHeads on Auto Layout.  We discussed using it for configuring complex dynamic table view cells and hypothesized on the possible performance implications of using it in tables with large amounts of data.

I just ran across this article I wanted to pass long:


The conclusion relates to our discussion:

My conclusion is that Auto Layout is great for views which are not created on the fly and where a few hundreds of a second more or less don't make a big impact. For these cases the benefits of Auto Layout can easily outweigh the small performance cost.
 
For views where the amount of time it takes to create them is crucial (like the contents of table view & collection view cells, paging views, etc.) you have to keep the view hierarchy very simple and closely watch the performance impact of Auto Layout. In these cases it might be worthwhile to try disabling Auto Layout before you go straight to drawing everything manually with Core Graphics.

Right now, the fastest scrolling performance with large data sets I've gotten (just under 60 fps according to Instruments) has been by overriding the drawRect method of the UITableViewCell subclass.  However, the code is a little annoying to maintain.

Anyway, if you're considering using Auto Layout, this article analyzing its performance is definitely worth a read.

- Aaron Brager
Reply all
Reply to author
Forward
0 new messages