RT
#import <mach/mach_time.h> double MachTimeToSecs(uint64_t time) { mach_timebase_info_data_t timebase; mach_timebase_info(&timebase); return (double)time * (double)timebase.numer / (double)timebase.denom /1e9; } - (void)doSomething { uint64_t beginTime = mach_absolute_time(); // 在这里放置你要检测效率的代码 uint64_t endTime = mach_absolute_time(); NSLog(@"Time taken to doSomething %g s",MachTimeToSecs(endTime - beginTime)); }
原文地址:http://blog.csdn.net/xietao3/article/details/43274341