Open az-oolloow opened 5 years ago
I guess this is due to the sorting capability which double the source and sorted data ? maybe the sorting should be delegated to view controller calling
By the sounds of it it sounds like it might be more than just the double the source.. I can see the issues here loading it all into memory, of course. @az-oolloow Could you create a sample project with the bare essentials that demonstrates the issue you explained? You can create a github repo or whatever you prefer, so we can check it out.
Any updates on this?
To do a simple test :
in DataTableWithDataSourceViewController.swift :
func randomString(_ length: Int) -> String {
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
return String((0..<length).map{ _ in letters.randomElement()! })
}
public func addDataSourceAfter() {
for _ in 1...10000 {
self.dataSource.append( [
DataTableValueType.string(randomString(12)),
DataTableValueType.string(randomString(8)),
DataTableValueType.string(randomString(10)),
DataTableValueType.string(randomString(15)),
DataTableValueType.float(175.25)
])
}
dataTable.reload()
}
Since sort is slow with huge data set, a spinner could be useful also, if sorting time > 0.2s for example
But I also think using 10000 entries is not really practical.... as of right now you have to scroll to the end, page by page. isn't there a way to jump the scroll in the collectionview ? i.e. tapping on the right scroll position would directly move you to that page. could be very useful
Or we could supply the datasource on the fly, but this does mean having to calculate the row heights somehow too.. I imagine this would provide a choppy experience.
Loading 10000 items isn't practical. There'll be memory issues too..
Why calculate the row height? Aren't they constants?
Custom heights can be returned.
If anyone has any suggestions I'd love to hear them.
Basically, looking at how the control is laid out, all the data has to be loaded into
currentRowViewModels
. So while the delegate has a good api that would allow it to provide data sequentially (e.g. from remote api or sqlite db), in practice all the data is loaded into memory in one go. So if you have just a measly 10K rows over 5 columns, performance is very poor because just to load the data the control does the foreach over that data...Look at UITableViewDataSource for ideas on improving this.