On Mar 27, 2006, at 4:08 PM, Eric Albert wrote: We have measured a performance advantage on PowerPC, yes, but remember that this is only for objc_msgSend itself. For most real Obj-C calls, there's more work in the method itself than in getting to the method in the first place. That said, it'll make accessors and things like that faster, but few applications have objc_msgSend itself as a performance bottleneck.
OK, chalk it up to testing error. I re-ran my tests on a quiescent dual 2GHz G5, with the following code:
#import <Foundation/Foundation.h>
@interface TestClass : NSObject { int val; }
- (int) val;
@end
@implementation TestClass
- (int) val { return val; }
@end
int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
TestClass *tc = [[TestClass alloc] init]; int i;
NSDate *startDate = [NSDate date];
for (i=0; i < 100000000; i++) { [tc val]; }
NSDate *endDate = [NSDate date];
NSLog(@"interval: %f", [endDate timeIntervalSinceDate:startDate]);
[pool release]; return 0; }
Building with -Os, the best time (out of three runs) without accelerated dispatch was 1.73 seconds. With accelerated dispatch, 1.21 seconds. So, ignoring the looping and method body overhead, we get roughly 17 nanoseconds per call vs 12 nanoseconds per call, which is a pretty decent improvement, all things considered.
- Ladd |