Re: Knowing when a NSArrayController is ready
Re: Knowing when a NSArrayController is ready
- Subject: Re: Knowing when a NSArrayController is ready
- From: "email@hidden" <email@hidden>
- Date: Sat, 24 Jan 2009 23:05:17 +0000
On 24 Jan 2009, at 18:41, Matt Neuburg wrote:
On or about 1/24/09 10:17 AM, thus spake "email@hidden"
<email@hidden>:
I am also having horrible performance problems.
A data set of 1500 items with a total on disk size of 1.8MB is taking
more than 30 secs to load.
Maybe NSArrayController -fetchWithRequest will improve things.
I would ask you the same question I just asked someone else on the
list: are
you using the XML persistent storage format? Because, if so, you
must expect
some delay, since even before you fetch any objects the entire XML
file must
be loaded into memory and parsed.
I use XML because I want human readability for my data, so startup
speed is
a sacrifice I am prepared to make. My data consists of about 5000
items, but
they are very simple; dealing with complex objects would take
considerably
longer, one assumes. In order to cave-man-instrument the startup
procedure
via NSLog, I do NOT prepare content or even bind my array controller's
managed object content in the nib; instead, I do it all manually in
awakeFromNib. Here are some NSLog timings:
2009-01-24 10:37:09.157 [788] awakening from nib
2009-01-24 10:37:09.269 [788] binding to MOC
2009-01-24 10:37:09.359 [788] creating whole shebang
2009-01-24 10:37:09.360 [788] adding persistent store
2009-01-24 10:37:13.877 [788] calling fetch
2009-01-24 10:37:14.192 [788] done calling fetch
Notice the big delay between "adding persistent store" and "calling
fetch";
that consists a single line of code (calling
addPersistentStoreWithType:).
So the delay there is nothing but the XML file being loaded and
parsed. m.
Hi Matt
I changed my store type to SQLite and noted an immediate improvement
in load times.
The biggest boost by far though came from setting NSObjectController
setUsesLazyFetching:YES.
The 10.5 release notes state that this can give a big boost and for an
NSArrayController bound to an NSTableView it seems very true.
The only down side is that searches are noticeably slower as the data
has to be retrieved from the store, if not already present, at search
time.
I did not use -fetchWithRequest but left - prepareContent = YES. All
bindings were set in the nib.
Core data has improved a lot of the years so perhaps the prohibition
on - prepareContent no longer applies.
But I agree that pulling all this stuff out of the nib lets you get a
lot close to the action.
Obviously the complexity of the model and the number/complexity of
derived properties will be a factor too.
My model is very simple, the most complex bit being extracting an
NString rep of an RTF data object for search purposes.
The NSTableView data now appears in about 1/5 of the time it did
previously!
With regard to your earlier point I put an observer on the
NSArrayController's arrangedObjects and received a single notification
as expected.
So I don't know why you were getting two notifications.
Thanks for your response - it put me on the right track!
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
Jonathan Mitchell
Central Conscious Unit
http://www.mugginsoft.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden