Skip to content

Instantly share code, notes, and snippets.

@kimhunter
Created October 1, 2011 06:10
Show Gist options
  • Save kimhunter/1255672 to your computer and use it in GitHub Desktop.
Save kimhunter/1255672 to your computer and use it in GitHub Desktop.
objective-c code inline code block profiling
#define KMProfile(MSG, CODE_TO_PROFILE) { \
NSDate *KMStartDate = [NSDate date]; \
NSTimeInterval KMduration; \
CODE_TO_PROFILE \
KMduration = [[NSDate date] timeIntervalSinceDate:KMStartDate]; \
NSLog(@"KMProfile: %@ TOOK %.0lfms (%.1lfs) ", MSG,(KMduration*1000) , KMduration); \
}
// Usage: (works well with something a bit more intensive but you get the gist)
KMProfile(@"test printf ", {
printf("%d", 452);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment