Skip to content

Instantly share code, notes, and snippets.

@jenshandersson
Last active December 18, 2015 03:58
Show Gist options
  • Save jenshandersson/5721994 to your computer and use it in GitHub Desktop.
Save jenshandersson/5721994 to your computer and use it in GitHub Desktop.
A simple way to profile execution time of a code snippet.
static CFAbsoluteTime JAProfilingBlock (void (^block)(void)) {
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
block ();
CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
return end - start;
}
#example usage
CFAbsoluteTime filteringTime = JAProfilingBlock(^{
[newArray filterUsingPredicate:self.filterPreficate];
});
NSLog(@"time to filter the array: %f", filteringTime);
@niltoft
Copy link

niltoft commented Jun 6, 2013

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment