?????????????????????????
????@autoreleasepool ????for ??????棬????????????????????????????????????????????????????????????????
?????????????for??????????????????
???????????????????????????????????????????????????????檔
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"start");
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
[self test1];
NSLog(@"?? %f"?? CFAbsoluteTimeGetCurrent() - start);
start = CFAbsoluteTimeGetCurrent();
[self test2];
NSLog(@"?? %f"?? CFAbsoluteTimeGetCurrent() - start);
NSLog(@"over");
}
- (void)test2 {
for (long i = 0; i < largeNumber; ++i) {
@autoreleasepool {
NSString *str = [NSString stringWithFormat:@"hello - %ld"?? i];
str = [str uppercaseString];
str = [str stringByAppendingString:@" - world"];
}
}
}
- (void)test1 {
@autoreleasepool {
for (long i = 0; i < largeNumber; ++i) {
NSString *str = [NSString stringWithFormat:@"hello - %ld"?? i];
str = [str uppercaseString];
str = [str stringByAppendingString:@" - world"];
}
}
}