Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1.  
  2. - (void)testSpeedOfSearchEmpty{
  3. NSMutableString *s = [NSMutableString string];
  4. for (int x=0; x<10000; x++){
  5. [s appendString:@" "];
  6. }
  7. [s appendString:@"x"];
  8. NSString *string = [s copy];
  9. [self measureBlock:^{
  10. for (NSInteger x=0; x<100000; x++){
  11. NSCharacterSet *inverted = [[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet];
  12. [string rangeOfCharacterFromSet:inverted];
  13. }
  14. }];
  15. }
  16.  
  17. - (void)testSpeedOfSearchFilled{
  18. NSMutableString *s = [NSMutableString string];
  19. for (int x=0; x<10000; x++){
  20. [s appendString:@" x"];
  21. }
  22. NSString *string = [s copy];
  23. [self measureBlock:^{
  24. for (NSInteger x=0; x<100000; x++){
  25. [string rangeOfCharacterFromSet:[[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet]];
  26. }
  27. }];
  28. }
  29.  
  30. - (void)testSpeedOfTrimEmpty{
  31. NSMutableString *s = [NSMutableString string];
  32. for (int x=0; x<10000; x++){
  33. [s appendString:@" "];
  34. }
  35. [s appendString:@"x"];
  36. NSString *string = [s copy];
  37. [self measureBlock:^{
  38. for (NSInteger x=0; x<100000; x++){
  39. [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
  40. }
  41. }];
  42. }
  43.  
  44. - (void)testSpeedOfTrimFilled{
  45. NSMutableString *s = [NSMutableString string];
  46. for (int x=0; x<10000; x++){
  47. [s appendString:@" x"];
  48. }
  49. NSString *string = [s copy];
  50. [self measureBlock:^{
  51. for (NSInteger x=0; x<100000; x++){
  52. [string stringByTrimmingCharactersInSet:[[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet]];
  53. }
  54. }];
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement