Skip to content

Commit

Permalink
Made SpeedTest for Full-Text searching longer
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Hillegass committed Feb 23, 2010
1 parent 1da6367 commit afd805d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
23 changes: 18 additions & 5 deletions CDSpeedTest/FullTextFetchTest.m
Expand Up @@ -12,11 +12,12 @@
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

uint64_t start = mach_absolute_time();

// Create the managed object context
NSManagedObjectContext *context = managedObjectContext(@"CDText");

uint64_t start = mach_absolute_time();

NSFetchRequest *fr = [[NSFetchRequest alloc] init];
NSEntityDescription *ed = [NSEntityDescription entityForName:@"Song"
inManagedObjectContext:context];
Expand All @@ -28,10 +29,22 @@ int main (int argc, const char * argv[]) {
NSArray *songsThatMatch = [context executeFetchRequest:fr
error:NULL];

for (NSManagedObject *song in songsThatMatch) {
[song valueForKey:@"title"];
}
NSLog(@"%d songs", [songsThatMatch count]);
NSLog(@"%d songs contain the string 'choice'", [songsThatMatch count]);

predicate = [NSPredicate predicateWithFormat:@"title contains[c] 'brain'"];
[fr setPredicate:predicate];
songsThatMatch = [context executeFetchRequest:fr
error:NULL];

NSLog(@"%d songs contain the string 'brain'", [songsThatMatch count]);

predicate = [NSPredicate predicateWithFormat:@"title contains[c] 'pets'"];
[fr setPredicate:predicate];
songsThatMatch = [context executeFetchRequest:fr
error:NULL];

NSLog(@"%d songs contain the string 'pets'", [songsThatMatch count]);


uint64_t end = mach_absolute_time();

Expand Down
34 changes: 23 additions & 11 deletions TCSpeedTest/FullTextFetchText.m
Expand Up @@ -9,11 +9,11 @@ int main (int argc, const char * argv[]) {

BNRStore *store = CreateStoreAtPath(@TEXTTEST_PATH);
if (!store) exit(EXIT_FAILURE);

NSError *err;
BNRTCIndexManager *indexManager = [[BNRTCIndexManager alloc] initWithPath:@TEXTTEST_PATH
error:&err];

if (!indexManager) {
NSLog(@"error = %@", [err localizedDescription]);
exit(EXIT_FAILURE);
Expand All @@ -23,22 +23,34 @@ int main (int argc, const char * argv[]) {
[indexManager release];

[store addClass:[Song class]];

uint64_t start = mach_absolute_time();

NSMutableArray *songsThatMatch = [store objectsForClass:[Song class]
matchingText:@"[[*choice*]]"
forKey:@"title"];
for (Song *song in songsThatMatch) {
[song title];
}
NSLog(@"%d songs fetched", [songsThatMatch count]);
matchingText:@"[[*choice*]]"
forKey:@"title"];
// for (Song *song in songsThatMatch) {
// [song title];
// }
NSLog(@"%d song titles contain 'choice'", [songsThatMatch count]);

songsThatMatch = [store objectsForClass:[Song class]
matchingText:@"[[*brain*]]"
forKey:@"title"];
NSLog(@"%d song titles contain 'brain'", [songsThatMatch count]);

songsThatMatch = [store objectsForClass:[Song class]
matchingText:@"[[*pets*]]"
forKey:@"title"];
NSLog(@"%d song titles contain 'pets'", [songsThatMatch count]);

uint64_t end = mach_absolute_time();


[store release];

[pool drain];

uint64_t end = mach_absolute_time();
LogElapsedTime(start, end);
return EXIT_SUCCESS;
}
4 changes: 2 additions & 2 deletions TCSpeedTest/TCSpeedTest.xcodeproj/project.pbxproj
Expand Up @@ -981,7 +981,7 @@
);
PREBINDING = NO;
PRODUCT_NAME = ComplexInsertTest;
RUN_CLANG_STATIC_ANALYZER = NO;
RUN_CLANG_STATIC_ANALYZER = YES;
};
name = Debug;
};
Expand All @@ -1004,7 +1004,7 @@
);
PREBINDING = NO;
PRODUCT_NAME = ComplexInsertTest;
RUN_CLANG_STATIC_ANALYZER = NO;
RUN_CLANG_STATIC_ANALYZER = YES;
ZERO_LINK = NO;
};
name = Release;
Expand Down

0 comments on commit afd805d

Please sign in to comment.