Skip navigation.
 
mlRe: sort descriptor optimization
FROM : Adam R. Maxwell
DATE : Tue Jul 04 19:44:34 2006

On Jul 2, 2006, at 16:53, Adam R. Maxwell wrote:

> Hi all,
>
> We have an application that uses a custom NSSortDescriptor subclass 
> to handle nil values and empty strings differently from default. 
> Essentially, it looks like this:


[...]

> It looks like -[NSSortDescriptor compareObject:toObject:] does some 
> caching of key paths, or somehow bypasses valueForKeyPath: 
> altogether, but I can't figure out how to do this.
>
> If anyone's interested in a test app to play with Shark, I've 
> posted it at <http://homepage.mac.com/amaxwell> as kvcTest.zip. 
> With our sort descriptor subclass, I'm seeing times in the ~50 
> second range on a 1.33 G4; with NSSortDescriptor, times are ~8 
> seconds.


Well, having received no advice on this matter, I ended up filing 
rdar://problem/4612866 against valueForKeyPath: and rdar://problem/
4612871 against array sorting when using an NSSortDescriptor subclass.

I also updated the sample project I posted, and I'm seeing the 
following times from it:

2006-07-04 10:31:42.926 kvcTest[5846] BDSKTableSortDescriptor:   
15.528615 seconds
2006-07-04 10:31:50.413 kvcTest[5846] NSSortDescriptor:           
7.472493 seconds
2006-07-04 10:32:30.665 kvcTest[5846] FastTrivialSortDescriptor: 
40.240286 seconds
2006-07-04 10:33:29.521 kvcTest[5846] TrivialSortDescriptor:     
58.854701 seconds

BDSKTableSortDescriptor is my best shot (to date) at optimizing our 
sort descriptor subclass; NSSortDescriptor is Apple's implementation; 
FastTrivialSortDescriptor uses my own implementation of 
valueForKeyPath:, and TrivialSortDescriptor uses Foundation's 
valueForKeyPath: (all use the same comparison selector and key path).

-- Adam

Related mailsAuthorDate
mlsort descriptor optimization Adam R. Maxwell Jul 3, 01:53
mlRe: sort descriptor optimization Adam R. Maxwell Jul 4, 19:44
mlRe: sort descriptor optimization Matt Neuburg Jul 5, 00:00
mlRe: sort descriptor optimization Adam R. Maxwell Jul 5, 00:43
mlRe: sort descriptor optimization Matt Neuburg Jul 5, 01:44
mlRe: sort descriptor optimization Adam R. Maxwell Jul 5, 02:16
mlRe: sort descriptor optimization James Bucanek Jul 5, 16:23