Skip to content

Instantly share code, notes, and snippets.

@blladnar
Created October 28, 2011 13:58
Show Gist options
  • Save blladnar/1322331 to your computer and use it in GitHub Desktop.
Save blladnar/1322331 to your computer and use it in GitHub Desktop.
Stopwatch for timing stuff
#import <mach/mach_time.h>
#define StopWatchStart() uint64_t startTime = mach_absolute_time()
#define StopWatchEnd(caption) uint64_t elapsed = mach_absolute_time() - startTime; static mach_timebase_info_data_t sTimebaseInfo; if ( sTimebaseInfo.denom == 0 ) { (void) mach_timebase_info(&sTimebaseInfo); } uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom / 1000000; DLog(@"%s: %qu ms\n", caption, elapsedNano)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment