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
This commit is contained in:
Nicola Pero 2001-10-30 16:14:44 +00:00
parent 780c7435ed
commit c87d214647

View file

@ -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++)
{