Skip to content

when I insert 1000 datas ? #148

@wwwang89

Description

@wwwang89
  • (void)insertObj
    {
    // Put some data in the table if there's not enough
    NSArray *allColors = [Color allInstances];
    NSUInteger numPeople = [Person numberOfInstances];
    NSTimeInterval date1 = [NSDate.date timeIntervalSince1970];
    NSLog(@"date1:%f",date1);
    while (numPeople < 1000) {
    Person *p = [Person new];
    [p save:^{
    p.name = [@"xiaohong" stringByAppendingString:[@(numPeople) stringValue]];//[RandomThings randomName];
    NSInteger num = numPeople;
    if (num >= allColors.count) {
    num = arc4random() % allColors.count;
    }
    Color *color = allColors[num];
    p.color = color;
    }];

      numPeople++;
    

    }
    NSLog(@"date2:%f",[NSDate.date timeIntervalSince1970]);
    }

the output result :
2017-07-10 15:13:43.624140 FCModelTest[14829:3666710] date1:1499670823.624041
2017-07-10 15:13:58.527835 FCModelTest[14829:3666710] date2:1499670838.527774

so it takes about 15s when I save 1000 datas, Is there anything wrong ?thanks for help~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions