#import <mach/mach.h>
#import <mach/mach_time.h>
- (void)test {
uint64_t start = mach_absolute_time();
// 这里放入你想要测量的代码
uint64_t end = mach_absolute_time();
uint64_t elapsed = end - start;
mach_timebase_info_data_t timebase;
mach_timebase_info(&timebase);
double elapsedNano = (double)elapsed * (double)timebase.numer / (double)timebase.denom;
NSLog(@"Elapsed Time: %f nanoseconds", elapsedNano);
}
网友评论