Created
December 1, 2013 02:08
-
-
Save Adlai-Holler/7727727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define kDebugMomentCount 10 | |
-(void)doDebugStuff { | |
[[TRSyncManager sharedSyncManager] suspendWithKey:@"DebugSuspension"]; | |
Trip *trip = [Trip findFirst]; // Get one somehow. withID is another good candidate | |
if(!trip) return; | |
double delayInSeconds = 1.0; // Wait for some assets to get tracked. | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
NSArray *assetURLs = [[[TRAssetsLibraryTracker shared] sortedAssets] subarrayWithRange:NSMakeRange(0, kDebugMomentCount)]; | |
NSMutableArray *moments = [NSMutableArray arrayWithCapacity:assetURLs.count]; | |
for(NSURL *url in assetURLs) { | |
LocalTripAsset *lta = [LocalTripAsset insertForTrip:trip assetURL:url]; | |
lta.stateValue = TRAssetStateAccepted; | |
[moments addObject:lta.moment]; | |
} | |
NSDate *start = [NSDate date]; | |
[[[Moment opToPOSTMetadataForMoments:moments] addSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { | |
NSTimeInterval elapsed = [[NSDate date] timeIntervalSinceDate:start]; | |
NSLog(@"Failed. Took %f",elapsed); | |
} failure:^(RKObjectRequestOperation *operation, NSError *error) { | |
NSTimeInterval elapsed = [[NSDate date] timeIntervalSinceDate:start]; | |
NSLog(@"Failed. Took %f",elapsed); | |
}] enqueue]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment