ios 内存检查及其性能测试
iphone4s : fc04f0ab6ae3e0ab0e8156a368b634c885b3e1d0
NSDate *start = [NSDate date];
if (dateFormatter == nil) {
for(int i = 0; i < 100000; i++){
[NSDateFormattersetDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
}
}
// do stuff...
NSTimeInterval timeInterval = fabs([start timeIntervalSinceNow]);
NSLog(@"RUN 10000 TIME CREATE Elapsed: %f ", timeInterval);//10万次构造耗时 TIME CREATE Elapsed: 0.865611
NSLog(@"dateformtter pointer size %d", sizeof(dateFormatter) );//4字节
NSLog(@"NSDateFormatter instance size %d", malloc_size(dateFormatter));