计算代码执行时间的方法
- 方法一
NSDate *began = [NSDate date];
NSData *data = [NSData dataWithContentsOfURL:url];
NSDate *end = [NSDate date];
NSLog(@"%f",[end timeIntervalSinceDate:began]);
- 方法二
CFTimeInterval began = CFAbsoluteTimeGetCurrent();
NSData *data = [NSData dataWithContentsOfURL:url];
CFTimeInterval end = CFAbsoluteTimeGetCurrent();
NSLog(@"%f", end - began);