Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - - (void)testSpeedOfSearchEmpty{
 - NSMutableString *s = [NSMutableString string];
 - for (int x=0; x<10000; x++){
 - [s appendString:@" "];
 - }
 - [s appendString:@"x"];
 - NSString *string = [s copy];
 - [self measureBlock:^{
 - for (NSInteger x=0; x<100000; x++){
 - NSCharacterSet *inverted = [[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet];
 - [string rangeOfCharacterFromSet:inverted];
 - }
 - }];
 - }
 - - (void)testSpeedOfSearchFilled{
 - NSMutableString *s = [NSMutableString string];
 - for (int x=0; x<10000; x++){
 - [s appendString:@" x"];
 - }
 - NSString *string = [s copy];
 - [self measureBlock:^{
 - for (NSInteger x=0; x<100000; x++){
 - [string rangeOfCharacterFromSet:[[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet]];
 - }
 - }];
 - }
 - - (void)testSpeedOfTrimEmpty{
 - NSMutableString *s = [NSMutableString string];
 - for (int x=0; x<10000; x++){
 - [s appendString:@" "];
 - }
 - [s appendString:@"x"];
 - NSString *string = [s copy];
 - [self measureBlock:^{
 - for (NSInteger x=0; x<100000; x++){
 - [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
 - }
 - }];
 - }
 - - (void)testSpeedOfTrimFilled{
 - NSMutableString *s = [NSMutableString string];
 - for (int x=0; x<10000; x++){
 - [s appendString:@" x"];
 - }
 - NSString *string = [s copy];
 - [self measureBlock:^{
 - for (NSInteger x=0; x<100000; x++){
 - [string stringByTrimmingCharactersInSet:[[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet]];
 - }
 - }];
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment