diff --git a/Testing/benchmark.m b/Testing/benchmark.m index a27682c14..3082d8de9 100755 --- a/Testing/benchmark.m +++ b/Testing/benchmark.m @@ -34,6 +34,10 @@ #define PRINT_TIMER(str) printf(" %-20s\t %6.3f \t %6.3f\n", str, \ [eTime timeIntervalSinceDate: sTime], \ [eTime timeIntervalSinceDate: sTime]/baseline) +#define PRINT_TIMER_NO_BASELINE(str) \ + printf(" %-20s\t %6.3f \t %6.3f\n", str, \ + [eTime timeIntervalSinceDate: sTime] - baseline, \ + [eTime timeIntervalSinceDate: sTime]/baseline - 1) #define AUTO_START id pool = [NSAutoreleasePool new] #define AUTO_END [pool release] @@ -48,6 +52,19 @@ Class rootClass; Class stringClass; IMP cstring; +@interface MyObject : NSObject +@end + +@implementation MyObject +@end + +@implementation MyObject (Category) +- (id) self +{ + return [super self]; +} +@end + void bench_object() { @@ -84,6 +101,17 @@ bench_object() END_TIMER; PRINT_TIMER("Class: 10 class method calls"); + obj = [MyObject new]; + + START_TIMER; + for (i = 0; i < MAX_COUNT * 10; i++) + { + id i; + i = [obj self]; + } + END_TIMER; + PRINT_TIMER_NO_BASELINE("Category: 10 super calls"); + START_TIMER; for (i = 0; i < MAX_COUNT; i++) {