GCD 之 dispatch_benchmark 测量指定代码块执行时间

uint64_t dispatch_benchmark(size_t count, void (^block)(void));
uint64_t n = dispatch_benchmark(10000, ^{
        @autoreleasepool {
            [self resizeImageByvImage:[UIImage imageNamed:@"a.png"]];
        }
});
//类名,方法,行数,用时
NSLog(@"[D] <%@|%@:%d> The average runtime for operation is %llu ns.",
          NSStringFromClass([self class]), NSStringFromSelector(_cmd), __LINE__, n);

执行 [self resizeImageByvImage:[UIImage imageNamed:@"a.png"]];方法10000次所用时间

你可能感兴趣的:(GCD 之 dispatch_benchmark 测量指定代码块执行时间)