Guest User

Untitled

a guest
Jan 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. //test method which roughly mimics how I normally fetch results
  2.  
  3. -(NSTimeInterval)fetchResultsTest
  4. {
  5. static NSString * const selectFavorites = @"SELECT songId, title FROM songs LIMIT 50";
  6. NSMutableArray *fetched = [NSMutableArray array];
  7.  
  8. FMResultSet *resultSet = [[self database] executeQuery:selectFavorites];
  9.  
  10. NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
  11.  
  12. while ([resultSet next])
  13. {
  14. Song *song = [Song songFromResultSet:resultSet];
  15. [fetched addObject:song];
  16. }
  17.  
  18. NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];
  19.  
  20. return (end - start);
  21. }
  22.  
  23. -(void)runTest
  24. {
  25. NSTimeInterval processTotal = 0;
  26.  
  27. for (int i = 0; i < 100; i++)
  28. {
  29. processTotal += [self fetchResultsTest];
  30. }
  31.  
  32. NSLog(@"Average time: %f", (processTotal/100));
  33. }
Add Comment
Please, Sign In to add comment