Comments (4)
I’ve had problems with UICollectionView’s
internal batch update process getting extremely slow with large updates. If you're using UICollectionView
, I would suggest profiling it.
I don't completely understand what you mean by "loading". Can you describe what components of TLIPT you're using, e.g. TLCollectionViewController
, TLIndexPathController
, etc. and how you're creating and updating your data model?
from tlindexpathtools.
Yes, perfomBatchUpdates is hidiously slow with >100 items.
By loading I mean; setting items
, which builds all the lookup tables. Easy to see in the Shuffle/Filter demo by making an array of 5k items (make sure they are unique).
from tlindexpathtools.
I was able to get the Shuffle demo with 5000 items in Simulator down to 2.5s from 15s. The remaining 2.5s was made up of:
- 2.0s in
[UICollectionView _endItemAnimations]
mainly manipulating index paths. There is nothing I can do about this. - 0.5s in
AutoReleasePoolPage::pop(void*)
. A lot of this is likely due to temporary objects created inTLIndexPathUpdates
, but I don't know how much this can be improved and it could be a significant undertaking that I don't have time for.
The issue is summarized as follows. Ultimately, the problem was that the data model items were arrays:
NSArray *items = @[
@[@"A", [UIColor colorWithHexRGB:0x443695]],
@[@"B", [UIColor colorWithHexRGB:0x00B1D7]],
@[@"C", [UIColor colorWithHexRGB:0xF42994]],
@[@"D", [UIColor colorWithHexRGB:0x0A0916]],
@[@"E", [UIColor colorWithHexRGB:0xF4E353]],
@[@"F", [UIColor colorWithHexRGB:0x537B28]],
];
TLIPT was calling isEqual
on these arrays a lot and this was really slow. The fix involves two changes. The first change was a performance optimization I made in TLIPT to eliminate a bunch of isEqual
calls. You'll need to update to version 0.3.8. The second change, which is something you'll probably need to do in our code, was to provide an explicit identifier for each data model item. isEqual
gets called on the identifier instead of the item and, with an appropriate choice of identifier, this is much, much faster.
Item identifiers are discussed in the TLIndexPathDataModel
API documentation in the "Item Identification" section. The short story is that, in some cases such as the Shuffle example, the item itself is used as the identifier. And if the item's isEqual
method is expensive, the data model will not scale. The way to fix this is to provide an explicit unique identifier with a fast isEqual
method, such as an NSString
. The various TLIndexPathDataModel
initializers provide a few options for specifying identifiers. In the Shuffle example, I used the block-based initializer and the first element of the array, i.e. the unique string, as the identifier:
self.indexPathController.dataModel = [[TLIndexPathDataModel alloc] initWithItems:items sectionNameBlock:nil identifierBlock:^id(id item) {
return item[0];
}];
Thats about it. Please let me know if this helps your project.
from tlindexpathtools.
No reply. Closing.
from tlindexpathtools.
Related Issues (20)
- TLCollectionViewController with fetchRequest delete NSManagedObject fault crash HOT 2
- Changing the TLIndexPathDataModel while animations under way causes crash HOT 1
- DataModel+IndexPathUpdates do not detect modified Core Data model objects HOT 2
- Realm HOT 3
- Same item in multiple sections: Possible? HOT 2
- Swift support HOT 4
- Warning : Duplicate Item Ignored (Noob Question) HOT 2
- Wrong optionality on controller: willUpdateDataModel: HOT 2
- Swift support HOT 1
- Swift Implementation Question HOT 2
- TLCollapsibleTableViewController
- Crash when reordering items HOT 2
- Unable to get dynamic height working HOT 4
- Cocoa Pod HOT 2
- TLTreeTableViewController: Keep only one expanded parent (close others) HOT 2
- NSManagedObject changes not detected by TLIndexPathController HOT 19
- Analysis Warning -- FYI HOT 1
- Another Suggestion Needed : Boxing Swift Structs HOT 4
- Non-ideal hash calculation HOT 3
- Drawback in case of adding dynamic data from API in multilevel expandable tableview/accordion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tlindexpathtools.