From afd805dcb5213105257fb234443545d206d77825 Mon Sep 17 00:00:00 2001 From: Aaron Hillegass Date: Tue, 23 Feb 2010 08:52:56 -0500 Subject: [PATCH] Made SpeedTest for Full-Text searching longer --- CDSpeedTest/FullTextFetchTest.m | 23 ++++++++++--- TCSpeedTest/FullTextFetchText.m | 34 +++++++++++++------ .../TCSpeedTest.xcodeproj/project.pbxproj | 4 +-- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/CDSpeedTest/FullTextFetchTest.m b/CDSpeedTest/FullTextFetchTest.m index 3cac792..27201ba 100644 --- a/CDSpeedTest/FullTextFetchTest.m +++ b/CDSpeedTest/FullTextFetchTest.m @@ -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]; @@ -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(); diff --git a/TCSpeedTest/FullTextFetchText.m b/TCSpeedTest/FullTextFetchText.m index f461b5d..dade870 100644 --- a/TCSpeedTest/FullTextFetchText.m +++ b/TCSpeedTest/FullTextFetchText.m @@ -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); @@ -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; } diff --git a/TCSpeedTest/TCSpeedTest.xcodeproj/project.pbxproj b/TCSpeedTest/TCSpeedTest.xcodeproj/project.pbxproj index b224971..94bc354 100644 --- a/TCSpeedTest/TCSpeedTest.xcodeproj/project.pbxproj +++ b/TCSpeedTest/TCSpeedTest.xcodeproj/project.pbxproj @@ -981,7 +981,7 @@ ); PREBINDING = NO; PRODUCT_NAME = ComplexInsertTest; - RUN_CLANG_STATIC_ANALYZER = NO; + RUN_CLANG_STATIC_ANALYZER = YES; }; name = Debug; }; @@ -1004,7 +1004,7 @@ ); PREBINDING = NO; PRODUCT_NAME = ComplexInsertTest; - RUN_CLANG_STATIC_ANALYZER = NO; + RUN_CLANG_STATIC_ANALYZER = YES; ZERO_LINK = NO; }; name = Release;