From 5401390bec8b88df6707ea1f1db2fd4c0fbe665a Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 30 Oct 2001 16:14:44 +0000 Subject: [PATCH] Added test showing performance hit on super calls in category methods git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11283 72102866-910b-0410-8b05-ffd578937521 --- Testing/benchmark.m | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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++) {