引入头文件:#import <mach/mach_time.h>
uint64_t start = mach_absolute_time();
// 执行的代码块
uint64_t end = mach_absolute_time();
mach_timebase_info_data_t info;
mach_timebase_info(&info);
uint64_t elapsed = end -start;
/// 毫秒
uint64_t space = elapsed * info.numer / info.denom / 1e6;
NSLog(@"耗时:%ld",space);