Skip to content

Instantly share code, notes, and snippets.

@K-Kevin
Created November 29, 2017 08:59
Show Gist options
  • Save K-Kevin/22ff29b808141ab36e6b7dd89388f4c9 to your computer and use it in GitHub Desktop.
Save K-Kevin/22ff29b808141ab36e6b7dd89388f4c9 to your computer and use it in GitHub Desktop.
iOS 知识点
##dispatch_benchmark-Monkey
GCD 之 dispatch_benchmark 测量指定代码块执行时间
#import <Foundation/Foundation.h>
// 声明GCD中dispatch_benchmark函数原型
extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
uint64_t n = dispatch_benchmark(100, ^{
NSLog(@"hello");
});
NSLog(@"Block 耗时多少纳秒 : %llu",n);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment