AlexDenisov / iActiveRecord

ActiveRecord for iOS without CoreData, only SQLite
http://alexdenisov.github.com/iActiveRecord/
MIT License
354 stars 50 forks source link

Improve read performance approximately 2x #31

Closed mgod closed 11 years ago

mgod commented 11 years ago

Minimize expensive calls in tight loops. This may not be worth accepting given the state of development on the sql calls right now. Tested by adding:

@property (nonatomic, readwrite) double doubleProperty;

to DecimalRecord and running this micro-benchmark:

it(@"should run some very basic performance tests", ^{
    NSDecimalNumber *acc = [NSDecimalNumber one];
    while (acc.floatValue < 10000) {
        DecimalRecord *record = [DecimalRecord newRecord];
        record.decimal = acc;
        record.doubleProperty = acc.doubleValue;
        [record save];
        acc = [acc decimalNumberByAdding:[NSDecimalNumber one]];
    }
    for(int i = 0; i < 5; i++) {
        NSDate *start = [NSDate date];
        [DecimalRecord allRecords];
        NSLog(@"Time elapsed: %f", [[NSDate date] timeIntervalSinceDate:start]);
    }
});
AlexDenisov commented 11 years ago

Thank you, @mgod.