• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?


  • Subject: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
  • From: Javigator <email@hidden>
  • Date: Fri, 15 Jul 2005 11:36:11 +0200

Tearing my code appart seems to point in a direction that the NSArrayController/bound NSTableView seems to be some kind of performance hog. Because when executing the object creation while pointing the NSArrayController (and bound table) to another entry in the master/detail structure the objects are created in less than 1 second (performance like I expected).
But when the currently updating master/detail entities are active in the controller and displaying in the table, it takes awefully long (>40 sec. for 600 obj.).


Guess I have to look at the NSArrayController (or, to be more correct, at the FilteringArrayController overload I use) for speeding things up. Or it's the table (one column should display a little thumbnail... maybe this slows things down).

Thanks for indirectly pointing me in (hoepfully) the correct direction! :-) I knew I was wrong blaming CoreData...

Best regards,
Joern Janoschek.



Am 15. Jul 2005 um 10:56 schrieb mmalcolm crawford:


On Jul 15, 2005, at 1:30 AM, Javigator wrote:


At some point in the application there's some data generation which initially is in the form of nested NSArrays. Top level array consists of around 600 NSArray objects, all of them containing 11 objects (they correspond to the attributes of Entity1). The goal is to convert this into CoreData entities to be stored and displayed in a table.
My current implementation looks simple and is working: Loop over those 600 objects, create an entity using NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: and fill in the data using setValue:forKey: for each of the attributes of the entity. Additionally set the relationship to the currently selected Entity2 object.
But on my PowerMac G5 1,8 SP (1st gen.) with 1,5 GB this conversion takes over 30 seconds - and that's without saving the data store! I'm really stunned because of this bad performance... I was thinking that the object creation shouldn't take more than one to three seconds.




A rather trivial test using two orders of magnitude the number of objects you state takes about 10 seconds on a 1.5MHz PowerBook. I suspect the problem lies elsewhere...


mmalc



[Entity1 has 12 attributes each with a default value set in the model.]



    int i;
    NSManagedObject *mo, *mo2;
    NSManagedObjectContext *context = [self managedObjectContext];

mo2 = [NSEntityDescription insertNewObjectForEntityForName:@"Entity2" inManagedObjectContext:context];



NSLog(@"Date: %@", [NSDate date]);
for (i = 0; i < 60000; i++) {
mo = [NSEntityDescription insertNewObjectForEntityForName:@"Entity" inManagedObjectContext:context];


NSMutableSet *relationship = [mo2 mutableSetValueForKey:@"newRelationship"];
[relationship addObject:mo];


    }
    NSLog(@"Date: %@", [NSDate date]);


Date: 2005-07-15 01:52:09 -0700 Date: 2005-07-15 01:52:20 -0700

_______________________________________________
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


_______________________________________________ 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
  • Follow-Ups:
    • Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
      • From: Sherm Pendley <email@hidden>
    • Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
      • From: mmalcolm crawford <email@hidden>
References: 
 >Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow? (From: Javigator <email@hidden>)
 >Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow? (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: CoreData & Spotlight
  • Next by Date: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
  • Previous by thread: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
  • Next by thread: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
  • Index(es):
    • Date
    • Thread