Last active
December 18, 2015 03:58
-
-
Save jensellfors/5721994 to your computer and use it in GitHub Desktop.
A simple way to profile execution time of a code snippet.
This file contains hidden or 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
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!