Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Car123

macrumors newbie
Original poster
Mar 1, 2011
10
0
I need to find the time that a certain block of code is taking to execute. Is there a 'tic toc' equivalent in objective C, like there is in matlab for example?
 
Code:
NSDate *start = [NSDate date];

// doing stuff

NSTimeInterval milliseconds = [start timeIntervalSinceNow];
 
Last edited:
Using mach_absolute_time() (from the <mach/mach_time.h> include) is more accurate for timing small intervals than NSDate. NSDate can get "compensated" both forwards and backwards by network time.
 
ended up using CFAbsoluteTimeGetCurrent() and CFTimeInterval, works just fine for what I need :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.