Last active
August 29, 2015 14:17
-
-
Save masakih/4cb935e3d551adfe465a to your computer and use it in GitHub Desktop.
Objctive-Cですよ、これは
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#include <objc/runtime.h> | |
int main( int argc, char *argv[]) | |
{ | |
id a = [[NSAutoreleasePool alloc] init]; | |
NSDate *startDate = [NSDate date]; | |
SEL sel0 = @selector(numberWithInteger:); | |
Class CNSNumber = [NSNumber class]; | |
Method m = class_getClassMethod(CNSNumber ,sel0); | |
IMP numberWithInteger = method_getImplementation(m); | |
SEL sel1 = @selector(addObject:); | |
m = class_getInstanceMethod([NSMutableArray class],sel1); | |
IMP addObject = method_getImplementation(m); | |
for( int i = 0; i < 1000000; i++) { | |
NSMutableArray *array = [NSMutableArray array]; | |
for( int n = 0; n < 100; n++) { | |
addObject(array, sel1, numberWithInteger(CNSNumber, sel0, n)); | |
} | |
} | |
NSDate *endDate = [NSDate date]; | |
NSTimeInterval interval = [endDate timeIntervalSinceDate:startDate]; | |
NSLog(@"%.3f秒", interval); | |
[a release]; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main( int argc, char *argv[]) { | |
@autoreleasepool { | |
NSDate *startDate = [NSDate date]; | |
for(int i = 0; i < 1000000; i++) { | |
NSMutableArray *array = [NSMutableArray array]; | |
for( int n = 0; n < 100; n++) { | |
[array addObject:[NSNumber numberWithInteger:n]]; | |
} | |
} | |
NSDate *endDate = [NSDate date]; | |
NSTimeinterval interval = [endDate timeIntervalSinceDate:startDate]; | |
NSLog(@"%.3f秒", interval); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment