mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
2dfb71be38
commit
5401390bec
1 changed files with 28 additions and 0 deletions
|
@ -34,6 +34,10 @@
|
||||||
#define PRINT_TIMER(str) printf(" %-20s\t %6.3f \t %6.3f\n", str, \
|
#define PRINT_TIMER(str) printf(" %-20s\t %6.3f \t %6.3f\n", str, \
|
||||||
[eTime timeIntervalSinceDate: sTime], \
|
[eTime timeIntervalSinceDate: sTime], \
|
||||||
[eTime timeIntervalSinceDate: sTime]/baseline)
|
[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_START id pool = [NSAutoreleasePool new]
|
||||||
#define AUTO_END [pool release]
|
#define AUTO_END [pool release]
|
||||||
|
@ -48,6 +52,19 @@ Class rootClass;
|
||||||
Class stringClass;
|
Class stringClass;
|
||||||
IMP cstring;
|
IMP cstring;
|
||||||
|
|
||||||
|
@interface MyObject : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation MyObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation MyObject (Category)
|
||||||
|
- (id) self
|
||||||
|
{
|
||||||
|
return [super self];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
void
|
void
|
||||||
bench_object()
|
bench_object()
|
||||||
{
|
{
|
||||||
|
@ -84,6 +101,17 @@ bench_object()
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("Class: 10 class method calls");
|
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;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT; i++)
|
for (i = 0; i < MAX_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue