Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
- Subject: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
- From: Javigator <email@hidden>
- Date: Tue, 19 Jul 2005 09:07:37 +0200
Am 15. Jul 2005 um 13:13 schrieb Sherm Pendley:
On Jul 15, 2005, at 5:36 AM, Javigator wrote:
Guess I have to look at the NSArrayController
Might I suggest using Shark? Shark will tell you exactly where your
app's time is being spent, so there's no need to guess about it.
sherm--
Well, Shark didn't me get any further, the weekend neither. I still
get 40 to 60 seconds object generation for 600 entities when the
NSTableView is wired to the NSArrayController that gets filled.
I let Shark sample the object generation code for the time it takes,
but I cannot make much of its output. There are thousands of samples
taking <0.0 percent of time (sure, that adds up), and a few trees
that take 2 to 3% of time. Looking at these they look like these are
all from Cocoa frameworks (AppKit, Foundation, CF, CoreData,...)... a
lot has to do with predicate stuff and Cocoa bindings, it looks like.
Aside from the problem that Shark doesn't show me my source code when
double clicking the samples (only the ASM, the Source button is
disabled (and yes, in the prefs I set the source path to my source
code path)), I really feel a little lost with the data that doesn't
give me a clue where my problem is...
Again the problem:
For testing I create around 600-700 CoreData entity based objects in
a loop (I should mention that it's a custom NSManagedObject subclass,
I don't know if this matters or not). The entity consists of 11
attributes which are filled from data residing in an NSArray of
NSArray. A loop over the outer array creates the objects and 11
setValue:forKey: are done on the object with the data out of the
inner NSArray (using objectAtIndex:). One of the setValue:forKey:
sets a maste object where the currently created obejct relates to
(CoreData relationship). That's basically it. Nothing fancy.
The entities can show up in a NSTableView (12 columns) powered by an
NSArrayController preparing the CoreData entities for it, but is
depended upon a master table (via binding the contentSet binding).
Now, when the contentSet binding is set to a master where no detail
data (= relationship objects) exists, and the app creates the 600
objects as described above, it takes its time (> 40 sec.). When the
detail table shows the relationship of another object and the master
currently getting the detail data is different, it doesn't take more
than 2 sec...
So, for me there's clearly a problem with the fact that there's a
bound NSArrayController/NSTableView getting the updates "live". But I
cannot figure out where the problem is and what to do about (frankly,
I even cannot figure out if my code is the problem or something
else). Toggling "automatically prepares content" for the
NSArrayController doesn't change anything to good. I checked my code
for notifications and stuff that maybe could be fired upon object
creation, but there is nothing. I even stripped my entity class from
all code to an almost empty code... no change. And Shark, well,... as
I said, to me the output looks like most of the time the code is
working its way through Cocoa frameworks.
I'm lost here. Gladly there's more than enough other work to be done
for the app... :-)
I'd appriciate any hints or tips for getting things straight with my
table view and with Shark!
Best regards,
Joern Janoschek.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden