Skip to content

Instantly share code, notes, and snippets.

@1951FDG
Created October 16, 2013 16:46
Show Gist options
  • Save 1951FDG/2a278636ffe7c46774c8 to your computer and use it in GitHub Desktop.
Save 1951FDG/2a278636ffe7c46774c8 to your computer and use it in GitHub Desktop.
Time code macro's
#import <mach/mach_time.h>
#define startTimer(e) uint64_t e = mach_absolute_time();
#define stopTimer(f, e, d) uint64_t f = mach_absolute_time(); printf("Total execution time for task named '%s': %g s\n", [d UTF8String], ((double)(f - e) / (double)NSEC_PER_SEC));
startTimer(baba);
stopTimer(bab1, baba, @"myTimerName");
#define JJLog(f, e, d) uint64_t f = mach_absolute_time(); printf("Total execution time for task named '%s': %llu ns\n", [d UTF8String], f - e);
#define JJLog(f, e) uint64_t f = mach_absolute_time(); printf("%s:%i %s:%llu\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, f - e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment