mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
* Source/GSPrivate.h (GS_REPLACE_CONSTANT_STRING): New macro.
* Source/externs.m: Initialize constant strings statically. (GSBuildStrings): Replace static strings with dynamic versions. * Testing/benchmark.m: Added tests for NSString -hash and -copy. Aligned ouput. * Testing/externs.m: New test. * Testing/GNUmakefile: Added externs.m test. Activated ADDITIONAL_TOOLS tests excluding gstcpport tests. * Source/Additions/GSCategories.m: Adjust declared lock type. Added comment. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18058 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
61cf6fa9e9
commit
4e4df7b974
7 changed files with 439 additions and 227 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2003-11-06 David Ayers <d.ayers@inode.at>
|
||||||
|
|
||||||
|
* Source/GSPrivate.h (GS_REPLACE_CONSTANT_STRING): New macro.
|
||||||
|
* Source/externs.m: Initialize constant strings statically.
|
||||||
|
(GSBuildStrings): Replace static strings with dynamic
|
||||||
|
versions.
|
||||||
|
* Testing/benchmark.m: Added tests for NSString -hash and
|
||||||
|
-copy. Aligned ouput.
|
||||||
|
* Testing/externs.m: New test.
|
||||||
|
* Testing/GNUmakefile: Added externs.m test. Activated
|
||||||
|
ADDITIONAL_TOOLS tests excluding gstcpport tests.
|
||||||
|
|
||||||
|
* Source/Additions/GSCategories.m: Adjust declared lock type.
|
||||||
|
Added comment.
|
||||||
|
|
||||||
2003-11-05 18:26 Richard Frith-Macdonald <rfm@gnu.org>
|
2003-11-05 18:26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* SSL/GSSSLHandle.m: Add support for server end handles.
|
* SSL/GSSSLHandle.m: Add support for server end handles.
|
||||||
|
|
|
@ -880,7 +880,7 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
|
||||||
* GNUstep specific (non-standard) additions to the NSLock class.
|
* GNUstep specific (non-standard) additions to the NSLock class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static NSRecursiveLock *local_lock = nil;
|
static GSLazyRecursiveLock *local_lock = nil;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This class only exists to provide
|
This class only exists to provide
|
||||||
|
@ -897,9 +897,13 @@ static NSRecursiveLock *local_lock = nil;
|
||||||
{
|
{
|
||||||
if (local_lock == nil)
|
if (local_lock == nil)
|
||||||
{
|
{
|
||||||
|
/* As we do not know whether creating custom locks
|
||||||
|
may implicitly create other locks,
|
||||||
|
we use a recursive lock. */
|
||||||
local_lock = [GSLazyRecursiveLock new];
|
local_lock = [GSLazyRecursiveLock new];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
GS_STATIC_INLINE id
|
GS_STATIC_INLINE id
|
||||||
|
|
|
@ -48,6 +48,28 @@
|
||||||
NSZoneFree(NSDefaultMallocZone(), _base); \
|
NSZoneFree(NSDefaultMallocZone(), _base); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro to consistently replace public accessable
|
||||||
|
* constant strings with dynamically allocated versions.
|
||||||
|
* This method assumes an initialzed NSStringClass symbol
|
||||||
|
* which contains the Class object of NSString. <br>
|
||||||
|
* Most public accesable strings are used in collection classes
|
||||||
|
* like NSDictionary, and therefor tend to receive -isEqual:
|
||||||
|
* messages (and therefore -hash) rather often. Statically
|
||||||
|
* allocated strings must calculate thier hash values where
|
||||||
|
* dynamically allocated strings can store them. This optimization
|
||||||
|
* is by far more effective than using NSString * const.
|
||||||
|
* The backdraw is that the memory managent cannot enforce these values
|
||||||
|
* to remain unaltered as it would for variables declared NSString * const.
|
||||||
|
* Yet the optimization of the stored hash value is currently deemed
|
||||||
|
* more important.
|
||||||
|
*/
|
||||||
|
#define GS_REPLACE_CONSTANT_STRING(ID) \
|
||||||
|
ID = [[NSStringClass alloc] initWithCString: [ID cString]]
|
||||||
|
/* Using cString here is OK here
|
||||||
|
because NXConstantString returns a pointer
|
||||||
|
to it's internal pointer. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function to get the name of a string encoding as an NSString.
|
* Function to get the name of a string encoding as an NSString.
|
||||||
*/
|
*/
|
||||||
|
|
315
Source/externs.m
315
Source/externs.m
|
@ -28,6 +28,8 @@
|
||||||
#include "Foundation/NSArray.h"
|
#include "Foundation/NSArray.h"
|
||||||
#include "Foundation/NSException.h"
|
#include "Foundation/NSException.h"
|
||||||
|
|
||||||
|
#include "GSPrivate.h"
|
||||||
|
|
||||||
/* Global lock to be used by classes when operating on any global
|
/* Global lock to be used by classes when operating on any global
|
||||||
data that invoke other methods which also access global; thus,
|
data that invoke other methods which also access global; thus,
|
||||||
creating the potential for deadlock. */
|
creating the potential for deadlock. */
|
||||||
|
@ -35,39 +37,39 @@
|
||||||
NSRecursiveLock *gnustep_global_lock = nil;
|
NSRecursiveLock *gnustep_global_lock = nil;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Connection Notification Strings.
|
* NSConnection Notification Strings.
|
||||||
*/
|
*/
|
||||||
NSString *NSConnectionDidDieNotification;
|
NSString *NSConnectionDidDieNotification = @"NSConnectionDidDieNotification";
|
||||||
|
|
||||||
NSString *NSConnectionDidInitializeNotification;
|
NSString *NSConnectionDidInitializeNotification = @"NSConnectionDidInitializeNotification";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NSThread Notifications
|
* NSThread Notifications
|
||||||
*/
|
*/
|
||||||
NSString *NSWillBecomeMultiThreadedNotification;
|
NSString *NSWillBecomeMultiThreadedNotification = @"NSWillBecomeMultiThreadedNotification";
|
||||||
|
|
||||||
NSString *NSThreadDidStartNotification;
|
NSString *NSThreadDidStartNotification = @"NSThreadDidStartNotification";
|
||||||
|
|
||||||
NSString *NSThreadWillExitNotification;
|
NSString *NSThreadWillExitNotification = @"NSThreadWillExitNotification";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Port Notifications
|
* Port Notifications
|
||||||
*/
|
*/
|
||||||
NSString *PortBecameInvalidNotification;
|
NSString *PortBecameInvalidNotification = @"PortBecameInvalidNotification";
|
||||||
|
|
||||||
NSString *InPortClientBecameInvalidNotification;
|
NSString *InPortClientBecameInvalidNotification = @"InPortClientBecameInvalidNotification";
|
||||||
|
|
||||||
NSString *InPortAcceptedClientNotification;
|
NSString *InPortAcceptedClientNotification = @"InPortAcceptedClientNotification";
|
||||||
|
|
||||||
|
|
||||||
NSString *NSPortDidBecomeInvalidNotification;
|
NSString *NSPortDidBecomeInvalidNotification = @"NSPortDidBecomeInvalidNotification";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* RunLoop modes */
|
/* RunLoop modes */
|
||||||
NSString *NSConnectionReplyMode;
|
NSString *NSConnectionReplyMode = @"NSConnectionReplyMode";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,133 +77,137 @@ NSString *NSConnectionReplyMode;
|
||||||
NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler;
|
NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler;
|
||||||
|
|
||||||
/* NSBundle */
|
/* NSBundle */
|
||||||
NSString *NSBundleDidLoadNotification;
|
NSString *NSBundleDidLoadNotification = @"NSBundleDidLoadNotification";
|
||||||
|
|
||||||
NSString *NSShowNonLocalizedStrings;
|
NSString *NSShowNonLocalizedStrings = @"NSShowNonLocalizedStrings";
|
||||||
|
|
||||||
NSString *NSLoadedClasses;
|
NSString *NSLoadedClasses = @"NSLoadedClasses";
|
||||||
|
|
||||||
|
|
||||||
/* Stream */
|
/* Stream */
|
||||||
NSString *StreamException;
|
NSString *StreamException = @"StreamException";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Standard domains */
|
/* Standard domains */
|
||||||
NSString *NSArgumentDomain;
|
NSString *NSArgumentDomain = @"NSArgumentDomain";
|
||||||
|
|
||||||
NSString *NSGlobalDomain;
|
NSString *NSGlobalDomain = @"NSGlobalDomain";
|
||||||
|
|
||||||
NSString *NSRegistrationDomain;
|
NSString *NSRegistrationDomain = @"NSRegistrationDomain";
|
||||||
|
|
||||||
|
|
||||||
/* Public notification */
|
/* Public notification */
|
||||||
NSString *NSUserDefaultsDidChangeNotification;
|
NSString *NSUserDefaultsDidChangeNotification = @"NSUserDefaultsDidChangeNotification";
|
||||||
|
|
||||||
|
|
||||||
/* Keys for language-dependent information */
|
/* Keys for language-dependent information */
|
||||||
NSString *NSWeekDayNameArray;
|
NSString *NSWeekDayNameArray = @"NSWeekDayNameArray";
|
||||||
|
|
||||||
NSString *NSShortWeekDayNameArray;
|
NSString *NSShortWeekDayNameArray = @"NSShortWeekDayNameArray";
|
||||||
|
|
||||||
NSString *NSMonthNameArray;
|
NSString *NSMonthNameArray = @"NSMonthNameArray";
|
||||||
|
|
||||||
NSString *NSShortMonthNameArray;
|
NSString *NSShortMonthNameArray = @"NSShortMonthNameArray";
|
||||||
|
|
||||||
NSString *NSTimeFormatString;
|
NSString *NSTimeFormatString = @"NSTimeFormatString";
|
||||||
|
|
||||||
NSString *NSDateFormatString;
|
NSString *NSDateFormatString = @"NSDateFormatString";
|
||||||
|
|
||||||
NSString *NSShortDateFormatString;
|
NSString *NSShortDateFormatString = @"NSShortDateFormatString";
|
||||||
|
|
||||||
NSString *NSTimeDateFormatString;
|
NSString *NSTimeDateFormatString = @"NSTimeDateFormatString";
|
||||||
|
|
||||||
NSString *NSShortTimeDateFormatString;
|
NSString *NSShortTimeDateFormatString = @"NSShortTimeDateFormatString";
|
||||||
|
|
||||||
NSString *NSCurrencySymbol;
|
NSString *NSCurrencySymbol = @"NSCurrencySymbol";
|
||||||
|
|
||||||
NSString *NSDecimalSeparator;
|
NSString *NSDecimalSeparator = @"NSDecimalSeparator";
|
||||||
|
|
||||||
NSString *NSThousandsSeparator;
|
NSString *NSThousandsSeparator = @"NSThousandsSeparator";
|
||||||
|
|
||||||
NSString *NSInternationalCurrencyString;
|
NSString *NSInternationalCurrencyString = @"NSInternationalCurrencyString";
|
||||||
|
|
||||||
NSString *NSCurrencyString;
|
NSString *NSCurrencyString = @"NSCurrencyString";
|
||||||
|
|
||||||
NSString *NSNegativeCurrencyFormatString;
|
NSString *NSNegativeCurrencyFormatString = @"NSNegativeCurrencyFormatString";
|
||||||
|
|
||||||
NSString *NSPositiveCurrencyFormatString;
|
NSString *NSPositiveCurrencyFormatString = @"NSPositiveCurrencyFormatString";
|
||||||
|
|
||||||
NSString *NSDecimalDigits;
|
NSString *NSDecimalDigits = @"NSDecimalDigits";
|
||||||
|
|
||||||
NSString *NSAMPMDesignation;
|
NSString *NSAMPMDesignation = @"NSAMPMDesignation";
|
||||||
|
|
||||||
|
|
||||||
NSString *NSHourNameDesignations;
|
NSString *NSHourNameDesignations = @"NSHourNameDesignations";
|
||||||
|
|
||||||
NSString *NSYearMonthWeekDesignations;
|
NSString *NSYearMonthWeekDesignations = @"NSYearMonthWeekDesignations";
|
||||||
|
|
||||||
NSString *NSEarlierTimeDesignations;
|
NSString *NSEarlierTimeDesignations = @"NSEarlierTimeDesignations";
|
||||||
|
|
||||||
NSString *NSLaterTimeDesignations;
|
NSString *NSLaterTimeDesignations = @"NSLaterTimeDesignations";
|
||||||
|
|
||||||
NSString *NSThisDayDesignations;
|
NSString *NSThisDayDesignations = @"NSThisDayDesignations";
|
||||||
|
|
||||||
NSString *NSNextDayDesignations;
|
NSString *NSNextDayDesignations = @"NSNextDayDesignations";
|
||||||
|
|
||||||
NSString *NSNextNextDayDesignations;
|
NSString *NSNextNextDayDesignations = @"NSNextNextDayDesignations";
|
||||||
|
|
||||||
NSString *NSPriorDayDesignations;
|
NSString *NSPriorDayDesignations = @"NSPriorDayDesignations";
|
||||||
|
|
||||||
NSString *NSDateTimeOrdering;
|
NSString *NSDateTimeOrdering = @"NSDateTimeOrdering";
|
||||||
|
|
||||||
|
|
||||||
/* These are in OPENSTEP 4.2 */
|
/* These are in OPENSTEP 4.2 */
|
||||||
NSString *NSLanguageCode;
|
NSString *NSLanguageCode = @"NSLanguageCode";
|
||||||
|
|
||||||
NSString *NSLanguageName;
|
NSString *NSLanguageName = @"NSLanguageName";
|
||||||
|
|
||||||
NSString *NSFormalName;
|
NSString *NSFormalName = @"NSFormalName";
|
||||||
|
|
||||||
/* For GNUstep */
|
/* For GNUstep */
|
||||||
NSString *NSLocale;
|
NSString *NSLocale = @"NSLocale";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keys for the NSDictionary returned by [NSConnection -statistics]
|
* Keys for the NSDictionary returned by [NSConnection -statistics]
|
||||||
*/
|
*/
|
||||||
/* These in OPENSTEP 4.2 */
|
/* These in OPENSTEP 4.2 */
|
||||||
NSString *NSConnectionRepliesReceived;
|
NSString *NSConnectionRepliesReceived = @"NSConnectionRepliesReceived";
|
||||||
|
|
||||||
NSString *NSConnectionRepliesSent;
|
NSString *NSConnectionRepliesSent = @"NSConnectionRepliesSent";
|
||||||
|
|
||||||
NSString *NSConnectionRequestsReceived;
|
NSString *NSConnectionRequestsReceived = @"NSConnectionRequestsReceived";
|
||||||
|
|
||||||
NSString *NSConnectionRequestsSent;
|
NSString *NSConnectionRequestsSent = @"NSConnectionRequestsSent";
|
||||||
|
|
||||||
/* These Are GNUstep extras */
|
/* These Are GNUstep extras */
|
||||||
NSString *NSConnectionLocalCount;
|
NSString *NSConnectionLocalCount = @"NSConnectionLocalCount";
|
||||||
|
|
||||||
NSString *NSConnectionProxyCount;
|
NSString *NSConnectionProxyCount = @"NSConnectionProxyCount";
|
||||||
|
|
||||||
/* Class description notification */
|
/* Class description notification */
|
||||||
NSString *NSClassDescriptionNeededForClassNotification;
|
NSString *NSClassDescriptionNeededForClassNotification = @"NSClassDescriptionNeededForClassNotification";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup function called when NSString is initialised.
|
* Opimization function called when NSObject is initialised.
|
||||||
* We make all the constant strings not be constant strings so they can
|
* We replace all the constant strings so they can
|
||||||
* cache their hash values and be used much more efficiently as keys in
|
* cache their hash values and be used much more efficiently as keys in
|
||||||
* dictionaries etc.
|
* dictionaries etc.
|
||||||
|
* We initialize with constant strings so that
|
||||||
|
* code executed before NSObject +initialize calls us,
|
||||||
|
* will have valid values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
GSBuildStrings()
|
GSBuildStrings()
|
||||||
{
|
{
|
||||||
static Class SClass = 0;
|
static Class NSStringClass = 0;
|
||||||
|
|
||||||
if (SClass == 0)
|
if (NSStringClass == 0)
|
||||||
{
|
{
|
||||||
SClass = [NSString class];
|
NSStringClass = [NSString class];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that NSString is initialized ... because we are called
|
* Ensure that NSString is initialized ... because we are called
|
||||||
|
@ -210,131 +216,64 @@ GSBuildStrings()
|
||||||
* Use performSelector: to avoid compiler warning about clash of
|
* Use performSelector: to avoid compiler warning about clash of
|
||||||
* return value types in two different versions of initialize.
|
* return value types in two different versions of initialize.
|
||||||
*/
|
*/
|
||||||
[SClass performSelector: @selector(initialize)];
|
[NSStringClass performSelector: @selector(initialize)];
|
||||||
|
|
||||||
InPortAcceptedClientNotification
|
GS_REPLACE_CONSTANT_STRING(InPortAcceptedClientNotification);
|
||||||
= [[SClass alloc] initWithCString:
|
GS_REPLACE_CONSTANT_STRING(InPortClientBecameInvalidNotification);
|
||||||
"InPortAcceptedClientNotification"];
|
GS_REPLACE_CONSTANT_STRING(NSAMPMDesignation);
|
||||||
InPortClientBecameInvalidNotification
|
GS_REPLACE_CONSTANT_STRING(NSArgumentDomain);
|
||||||
= [[SClass alloc] initWithCString:
|
GS_REPLACE_CONSTANT_STRING(NSBundleDidLoadNotification);
|
||||||
"InPortClientBecameInvalidNotification"];
|
GS_REPLACE_CONSTANT_STRING(NSClassDescriptionNeededForClassNotification);
|
||||||
NSAMPMDesignation
|
GS_REPLACE_CONSTANT_STRING(NSConnectionDidDieNotification);
|
||||||
= [[SClass alloc] initWithCString: "NSAMPMDesignation"];
|
GS_REPLACE_CONSTANT_STRING(NSConnectionDidInitializeNotification);
|
||||||
NSArgumentDomain
|
GS_REPLACE_CONSTANT_STRING(NSConnectionLocalCount);
|
||||||
= [[SClass alloc] initWithCString: "NSArgumentDomain"];
|
GS_REPLACE_CONSTANT_STRING(NSConnectionProxyCount);
|
||||||
NSBundleDidLoadNotification
|
GS_REPLACE_CONSTANT_STRING(NSConnectionRepliesReceived);
|
||||||
= [[SClass alloc] initWithCString: "NSBundleDidLoadNotification"];
|
GS_REPLACE_CONSTANT_STRING(NSConnectionRepliesSent);
|
||||||
NSConnectionDidDieNotification
|
GS_REPLACE_CONSTANT_STRING(NSConnectionReplyMode);
|
||||||
= [[SClass alloc] initWithCString:
|
GS_REPLACE_CONSTANT_STRING(NSConnectionRequestsReceived);
|
||||||
"NSConnectionDidDieNotification"];
|
GS_REPLACE_CONSTANT_STRING(NSConnectionRequestsSent);
|
||||||
NSConnectionDidInitializeNotification
|
GS_REPLACE_CONSTANT_STRING(NSCurrencyString);
|
||||||
= [[SClass alloc] initWithCString:
|
GS_REPLACE_CONSTANT_STRING(NSCurrencySymbol);
|
||||||
"NSConnectionDidInitializeNotification"];
|
GS_REPLACE_CONSTANT_STRING(NSDateFormatString);
|
||||||
NSConnectionLocalCount
|
GS_REPLACE_CONSTANT_STRING(NSDateTimeOrdering);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionLocalCount"];
|
GS_REPLACE_CONSTANT_STRING(NSDecimalDigits);
|
||||||
NSConnectionProxyCount
|
GS_REPLACE_CONSTANT_STRING(NSDecimalSeparator);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionProxyCount"];
|
GS_REPLACE_CONSTANT_STRING(NSEarlierTimeDesignations);
|
||||||
NSConnectionRepliesReceived
|
GS_REPLACE_CONSTANT_STRING(NSFormalName);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionRepliesReceived"];
|
GS_REPLACE_CONSTANT_STRING(NSGlobalDomain);
|
||||||
NSConnectionRepliesSent
|
GS_REPLACE_CONSTANT_STRING(NSHourNameDesignations);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionRepliesSent"];
|
GS_REPLACE_CONSTANT_STRING(NSInternationalCurrencyString);
|
||||||
NSConnectionReplyMode
|
GS_REPLACE_CONSTANT_STRING(NSLanguageCode);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionReplyMode"];
|
GS_REPLACE_CONSTANT_STRING(NSLanguageName);
|
||||||
NSConnectionRequestsReceived
|
GS_REPLACE_CONSTANT_STRING(NSLaterTimeDesignations);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionRequestsReceived"];
|
GS_REPLACE_CONSTANT_STRING(NSLoadedClasses);
|
||||||
NSConnectionRequestsSent
|
GS_REPLACE_CONSTANT_STRING(NSLocale);
|
||||||
= [[SClass alloc] initWithCString: "NSConnectionRequestsSent"];
|
GS_REPLACE_CONSTANT_STRING(NSMonthNameArray);
|
||||||
NSCurrencyString
|
GS_REPLACE_CONSTANT_STRING(NSNegativeCurrencyFormatString);
|
||||||
= [[SClass alloc] initWithCString: "NSCurrencyString"];
|
GS_REPLACE_CONSTANT_STRING(NSNextDayDesignations);
|
||||||
NSCurrencySymbol
|
GS_REPLACE_CONSTANT_STRING(NSNextNextDayDesignations);
|
||||||
= [[SClass alloc] initWithCString: "NSCurrencySymbol"];
|
GS_REPLACE_CONSTANT_STRING(NSPortDidBecomeInvalidNotification);
|
||||||
NSDateFormatString
|
GS_REPLACE_CONSTANT_STRING(NSPositiveCurrencyFormatString);
|
||||||
= [[SClass alloc] initWithCString: "NSDateFormatString"];
|
GS_REPLACE_CONSTANT_STRING(NSPriorDayDesignations);
|
||||||
NSDateTimeOrdering
|
GS_REPLACE_CONSTANT_STRING(NSRegistrationDomain);
|
||||||
= [[SClass alloc] initWithCString: "NSDateTimeOrdering"];
|
GS_REPLACE_CONSTANT_STRING(NSShortDateFormatString);
|
||||||
NSDecimalDigits
|
GS_REPLACE_CONSTANT_STRING(NSShortMonthNameArray);
|
||||||
= [[SClass alloc] initWithCString: "NSDecimalDigits"];
|
GS_REPLACE_CONSTANT_STRING(NSShortTimeDateFormatString);
|
||||||
NSDecimalSeparator
|
GS_REPLACE_CONSTANT_STRING(NSShortWeekDayNameArray);
|
||||||
= [[SClass alloc] initWithCString: "NSDecimalSeparator"];
|
GS_REPLACE_CONSTANT_STRING(NSShowNonLocalizedStrings);
|
||||||
NSEarlierTimeDesignations
|
GS_REPLACE_CONSTANT_STRING(NSThisDayDesignations);
|
||||||
= [[SClass alloc] initWithCString: "NSEarlierTimeDesignations"];
|
GS_REPLACE_CONSTANT_STRING(NSThousandsSeparator);
|
||||||
NSFormalName
|
GS_REPLACE_CONSTANT_STRING(NSThreadDidStartNotification);
|
||||||
= [[SClass alloc] initWithCString: "NSFormalName"];
|
GS_REPLACE_CONSTANT_STRING(NSThreadWillExitNotification);
|
||||||
NSGlobalDomain
|
GS_REPLACE_CONSTANT_STRING(NSTimeDateFormatString);
|
||||||
= [[SClass alloc] initWithCString: "NSGlobalDomain"];
|
GS_REPLACE_CONSTANT_STRING(NSTimeFormatString);
|
||||||
NSHourNameDesignations
|
GS_REPLACE_CONSTANT_STRING(NSUserDefaultsDidChangeNotification);
|
||||||
= [[SClass alloc] initWithCString: "NSHourNameDesignations"];
|
GS_REPLACE_CONSTANT_STRING(NSWeekDayNameArray);
|
||||||
NSInternationalCurrencyString
|
GS_REPLACE_CONSTANT_STRING(NSWillBecomeMultiThreadedNotification);
|
||||||
= [[SClass alloc] initWithCString: "NSInternationalCurrencyString"];
|
GS_REPLACE_CONSTANT_STRING(NSYearMonthWeekDesignations);
|
||||||
NSLanguageCode
|
GS_REPLACE_CONSTANT_STRING(PortBecameInvalidNotification);
|
||||||
= [[SClass alloc] initWithCString: "NSLanguageCode"];
|
GS_REPLACE_CONSTANT_STRING(StreamException);
|
||||||
NSLanguageName
|
|
||||||
= [[SClass alloc] initWithCString: "NSLanguageName"];
|
|
||||||
NSLaterTimeDesignations
|
|
||||||
= [[SClass alloc] initWithCString: "NSLaterTimeDesignations"];
|
|
||||||
NSLoadedClasses
|
|
||||||
= [[SClass alloc] initWithCString: "NSLoadedClasses"];
|
|
||||||
NSLocale
|
|
||||||
= [[SClass alloc] initWithCString: "NSLocale"];
|
|
||||||
NSMonthNameArray
|
|
||||||
= [[SClass alloc] initWithCString: "NSMonthNameArray"];
|
|
||||||
NSNegativeCurrencyFormatString
|
|
||||||
= [[SClass alloc] initWithCString:
|
|
||||||
"NSNegativeCurrencyFormatString"];
|
|
||||||
NSNextDayDesignations
|
|
||||||
= [[SClass alloc] initWithCString: "NSNextDayDesignations"];
|
|
||||||
NSNextNextDayDesignations
|
|
||||||
= [[SClass alloc] initWithCString: "NSNextNextDayDesignations"];
|
|
||||||
NSPortDidBecomeInvalidNotification
|
|
||||||
= [[SClass alloc] initWithCString:
|
|
||||||
"NSPortDidBecomeInvalidNotification"];
|
|
||||||
NSPositiveCurrencyFormatString
|
|
||||||
= [[SClass alloc] initWithCString:
|
|
||||||
"NSPositiveCurrencyFormatString"];
|
|
||||||
NSPriorDayDesignations
|
|
||||||
= [[SClass alloc] initWithCString: "NSPriorDayDesignations"];
|
|
||||||
NSRegistrationDomain
|
|
||||||
= [[SClass alloc] initWithCString: "NSRegistrationDomain"];
|
|
||||||
NSShortDateFormatString
|
|
||||||
= [[SClass alloc] initWithCString: "NSShortDateFormatString"];
|
|
||||||
NSShortMonthNameArray
|
|
||||||
= [[SClass alloc] initWithCString: "NSShortMonthNameArray"];
|
|
||||||
NSShortTimeDateFormatString
|
|
||||||
= [[SClass alloc] initWithCString: "NSShortTimeDateFormatString"];
|
|
||||||
NSShortWeekDayNameArray
|
|
||||||
= [[SClass alloc] initWithCString: "NSShortWeekDayNameArray"];
|
|
||||||
NSShowNonLocalizedStrings
|
|
||||||
= [[SClass alloc] initWithCString: "NSShowNonLocalizedStrings"];
|
|
||||||
NSThisDayDesignations
|
|
||||||
= [[SClass alloc] initWithCString: "NSThisDayDesignations"];
|
|
||||||
NSThousandsSeparator
|
|
||||||
= [[SClass alloc] initWithCString: "NSThousandsSeparator"];
|
|
||||||
NSThreadDidStartNotification
|
|
||||||
= [[SClass alloc] initWithCString: "NSThreadDidStartNotification"];
|
|
||||||
NSThreadWillExitNotification
|
|
||||||
= [[SClass alloc] initWithCString: "NSThreadWillExitNotification"];
|
|
||||||
NSTimeDateFormatString
|
|
||||||
= [[SClass alloc] initWithCString: "NSTimeDateFormatString"];
|
|
||||||
NSTimeFormatString
|
|
||||||
= [[SClass alloc] initWithCString: "NSTimeFormatString"];
|
|
||||||
NSUserDefaultsDidChangeNotification
|
|
||||||
= [[SClass alloc] initWithCString:
|
|
||||||
"NSUserDefaultsDidChangeNotification"];
|
|
||||||
NSWeekDayNameArray
|
|
||||||
= [[SClass alloc] initWithCString: "NSWeekDayNameArray"];
|
|
||||||
NSWillBecomeMultiThreadedNotification
|
|
||||||
= [[SClass alloc] initWithCString:
|
|
||||||
"NSWillBecomeMultiThreadedNotification"];
|
|
||||||
NSYearMonthWeekDesignations
|
|
||||||
= [[SClass alloc] initWithCString: "NSYearMonthWeekDesignations"];
|
|
||||||
PortBecameInvalidNotification
|
|
||||||
= [[SClass alloc] initWithCString: "PortBecameInvalidNotification"];
|
|
||||||
StreamException
|
|
||||||
= [[SClass alloc] initWithCString: "StreamException"];
|
|
||||||
|
|
||||||
NSClassDescriptionNeededForClassNotification
|
|
||||||
= [[SClass alloc] initWithCString:
|
|
||||||
"NSClassDescriptionNeededForClassNotification"];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ CHECKABLE_TOOLS = \
|
||||||
benchmark \
|
benchmark \
|
||||||
call \
|
call \
|
||||||
containers \
|
containers \
|
||||||
|
exported-strings \
|
||||||
fref \
|
fref \
|
||||||
gslock \
|
gslock \
|
||||||
nsarchiver \
|
nsarchiver \
|
||||||
|
@ -70,13 +71,11 @@ TEST_TOOL_NAME = $(CHECKABLE_TOOLS)
|
||||||
# Don't make these normally
|
# Don't make these normally
|
||||||
ADDITIONAL_TOOLS = \
|
ADDITIONAL_TOOLS = \
|
||||||
diningPhilosophers \
|
diningPhilosophers \
|
||||||
gstcpport-client \
|
|
||||||
gstcpport-server \
|
|
||||||
nsconnection_client \
|
nsconnection_client \
|
||||||
nsconnection_server \
|
nsconnection_server \
|
||||||
|
|
||||||
# TEST_TOOL_NAME += nsconnection_client nsconnection_server
|
TEST_TOOL_NAME += $(ADDITIONAL_TOOLS)
|
||||||
TEST_TOOL_NAME += nsconnection_client nsconnection_server $(ADDITIONAL_TOOLS)
|
# TEST_TOOL_NAME += gstcpport-client gstcpport-server
|
||||||
|
|
||||||
# The tool Objective-C source files to be compiled
|
# The tool Objective-C source files to be compiled
|
||||||
awake_OBJC_FILES = awake.m
|
awake_OBJC_FILES = awake.m
|
||||||
|
@ -85,6 +84,7 @@ benchmark_OBJC_FILES = benchmark.m
|
||||||
call_OBJC_FILES = call.m
|
call_OBJC_FILES = call.m
|
||||||
containers_OBJC_FILES = containers.m
|
containers_OBJC_FILES = containers.m
|
||||||
diningPhilosophers_OBJC_FILES = diningPhilosophers.m
|
diningPhilosophers_OBJC_FILES = diningPhilosophers.m
|
||||||
|
exported-strings_OBJC_FILES = exported-strings.m
|
||||||
fref_OBJC_FILES = fref.m
|
fref_OBJC_FILES = fref.m
|
||||||
gslock_OBJC_FILES = gslock.m
|
gslock_OBJC_FILES = gslock.m
|
||||||
gstcpport-client_OBJC_FILES = gstcpport-client.m
|
gstcpport-client_OBJC_FILES = gstcpport-client.m
|
||||||
|
|
|
@ -80,7 +80,7 @@ bench_object()
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
baseline = [eTime timeIntervalSinceDate: sTime];
|
baseline = [eTime timeIntervalSinceDate: sTime];
|
||||||
PRINT_TIMER("Baseline: 10 method calls");
|
PRINT_TIMER("Baseline: 10 method calls\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT; i++)
|
for (i = 0; i < MAX_COUNT; i++)
|
||||||
|
@ -99,7 +99,7 @@ bench_object()
|
||||||
i = [NSMutableDictionary class];
|
i = [NSMutableDictionary class];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("Class: 10 class method calls");
|
PRINT_TIMER("Class: 10 class method calls\t\t");
|
||||||
|
|
||||||
obj = [MyObject new];
|
obj = [MyObject new];
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ bench_object()
|
||||||
i = [obj self];
|
i = [obj self];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER_NO_BASELINE("Category: 10 super calls");
|
PRINT_TIMER_NO_BASELINE("Category: 10 super calls\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT; i++)
|
for (i = 0; i < MAX_COUNT; i++)
|
||||||
|
@ -129,7 +129,7 @@ bench_object()
|
||||||
i = NSClassFromString (@"NSMutableDictionary");
|
i = NSClassFromString (@"NSMutableDictionary");
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("Function: 10 NSClassFromStr");
|
PRINT_TIMER("Function: 10 NSClassFromStr\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
myZone = NSCreateZone(2048, 2048, 1);
|
myZone = NSCreateZone(2048, 2048, 1);
|
||||||
|
@ -140,7 +140,7 @@ bench_object()
|
||||||
}
|
}
|
||||||
NSRecycleZone(myZone);
|
NSRecycleZone(myZone);
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("Function: 1 zone alloc/free");
|
PRINT_TIMER("Function: 1 zone alloc/free\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
myZone = NSCreateZone(2048, 2048, 0);
|
myZone = NSCreateZone(2048, 2048, 0);
|
||||||
|
@ -151,7 +151,7 @@ bench_object()
|
||||||
}
|
}
|
||||||
NSRecycleZone(myZone);
|
NSRecycleZone(myZone);
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("Function: 1 zone2alloc/free");
|
PRINT_TIMER("Function: 1 zone2alloc/free\t\t");
|
||||||
|
|
||||||
myZone = NSDefaultMallocZone();
|
myZone = NSDefaultMallocZone();
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -161,7 +161,7 @@ bench_object()
|
||||||
NSZoneFree(myZone, mem);
|
NSZoneFree(myZone, mem);
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("Function: 1 def alloc/free");
|
PRINT_TIMER("Function: 1 def alloc/free\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
myZone = NSCreateZone(2048, 2048, 1);
|
myZone = NSCreateZone(2048, 2048, 1);
|
||||||
|
@ -172,7 +172,7 @@ bench_object()
|
||||||
}
|
}
|
||||||
NSRecycleZone(myZone);
|
NSRecycleZone(myZone);
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSObject: 1 zone all/init/rel");
|
PRINT_TIMER("NSObject: 1 zone all/init/rel\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
myZone = NSCreateZone(2048, 2048, 0);
|
myZone = NSCreateZone(2048, 2048, 0);
|
||||||
|
@ -183,7 +183,7 @@ bench_object()
|
||||||
}
|
}
|
||||||
NSRecycleZone(myZone);
|
NSRecycleZone(myZone);
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSObject: 1 zone2all/init/rel");
|
PRINT_TIMER("NSObject: 1 zone2all/init/rel\t\t");
|
||||||
|
|
||||||
myZone = NSDefaultMallocZone();
|
myZone = NSDefaultMallocZone();
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -193,7 +193,7 @@ bench_object()
|
||||||
[obj release];
|
[obj release];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSObject: 1 def all/init/rel");
|
PRINT_TIMER("NSObject: 1 def all/init/rel\t\t");
|
||||||
|
|
||||||
obj = [rootClass new];
|
obj = [rootClass new];
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -203,7 +203,7 @@ bench_object()
|
||||||
[obj release];
|
[obj release];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSObject: 10 retain/rel");
|
PRINT_TIMER("NSObject: 10 retain/rel\t\t");
|
||||||
[obj release];
|
[obj release];
|
||||||
|
|
||||||
obj = [rootClass new];
|
obj = [rootClass new];
|
||||||
|
@ -214,7 +214,7 @@ bench_object()
|
||||||
[obj retain];
|
[obj retain];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSObject: 10 autorel/ret");
|
PRINT_TIMER("NSObject: 10 autorel/ret\t\t");
|
||||||
[obj release];
|
[obj release];
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -223,7 +223,7 @@ bench_object()
|
||||||
[rootClass instancesRespondToSelector: @selector(hash)];
|
[rootClass instancesRespondToSelector: @selector(hash)];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("ObjC: 10 inst responds to sel");
|
PRINT_TIMER("ObjC: 10 inst responds to sel\t\t");
|
||||||
|
|
||||||
mutex = objc_mutex_allocate();
|
mutex = objc_mutex_allocate();
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -233,7 +233,7 @@ bench_object()
|
||||||
objc_mutex_unlock(mutex);
|
objc_mutex_unlock(mutex);
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("ObjC: 10 objc_mutex_lock/unl");
|
PRINT_TIMER("ObjC: 10 objc_mutex_lock/unl\t\t");
|
||||||
objc_mutex_deallocate(mutex);
|
objc_mutex_deallocate(mutex);
|
||||||
|
|
||||||
obj = [NSLock new];
|
obj = [NSLock new];
|
||||||
|
@ -244,7 +244,7 @@ bench_object()
|
||||||
[obj unlock];
|
[obj unlock];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSLock: 10 lock/unlock");
|
PRINT_TIMER("NSLock: 10 lock/unlock\t\t");
|
||||||
[obj release];
|
[obj release];
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ bench_array()
|
||||||
[array addObject: strings[i/10]];
|
[array addObject: strings[i/10]];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSArray (10 addObject:)");
|
PRINT_TIMER("NSArray (10 addObject:)\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT/100; i++)
|
for (i = 0; i < MAX_COUNT/100; i++)
|
||||||
|
@ -281,7 +281,7 @@ bench_array()
|
||||||
[array indexOfObject: strings[i]];
|
[array indexOfObject: strings[i]];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSArray (1/100 indexOfObj)");
|
PRINT_TIMER("NSArray (1/100 indexOfObj)\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT/100; i++)
|
for (i = 0; i < MAX_COUNT/100; i++)
|
||||||
|
@ -289,7 +289,7 @@ bench_array()
|
||||||
[array indexOfObjectIdenticalTo: strings[i]];
|
[array indexOfObjectIdenticalTo: strings[i]];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSArray (1/100 indexIdent)");
|
PRINT_TIMER("NSArray (1/100 indexIdent)\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < 1; i++)
|
for (i = 0; i < 1; i++)
|
||||||
|
@ -297,7 +297,7 @@ bench_array()
|
||||||
[array makeObjectsPerformSelector: @selector(hash)];
|
[array makeObjectsPerformSelector: @selector(hash)];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSArray (once perform)");
|
PRINT_TIMER("NSArray (once perform)\t\t");
|
||||||
AUTO_END;
|
AUTO_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ bench_dict()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSDict (1 setObject:) ");
|
PRINT_TIMER("NSDict (1 setObject:) \t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT; i++)
|
for (i = 0; i < MAX_COUNT; i++)
|
||||||
|
@ -345,7 +345,7 @@ bench_dict()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSDict (10 objectFor:) ");
|
PRINT_TIMER("NSDict (10 objectFor:) \t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT*10; i++)
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
@ -353,7 +353,7 @@ bench_dict()
|
||||||
[dict count];
|
[dict count];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSDictionary (10 count)");
|
PRINT_TIMER("NSDictionary (10 count)\t\t");
|
||||||
|
|
||||||
obj2 = [dict copy];
|
obj2 = [dict copy];
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -362,7 +362,7 @@ bench_dict()
|
||||||
[dict isEqual: obj2];
|
[dict isEqual: obj2];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSDict (ten times isEqual:)");
|
PRINT_TIMER("NSDict (ten times isEqual:)\t\t");
|
||||||
AUTO_END;
|
AUTO_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ bench_str()
|
||||||
str = [stringClass stringWithCString: "hello world"];
|
str = [stringClass stringWithCString: "hello world"];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1 cstring:) ");
|
PRINT_TIMER("NSString (1 cstring:) \t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT*10; i++)
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
@ -422,7 +422,64 @@ bench_str()
|
||||||
[str length];
|
[str length];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (10 length) ");
|
PRINT_TIMER("NSString (10 length) \t\t");
|
||||||
|
|
||||||
|
START_TIMER;
|
||||||
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
{
|
||||||
|
[str copy];
|
||||||
|
}
|
||||||
|
END_TIMER;
|
||||||
|
PRINT_TIMER("NSString (10 copy) <initWithCString:> ");
|
||||||
|
|
||||||
|
str = @"ConstantString";
|
||||||
|
START_TIMER;
|
||||||
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
{
|
||||||
|
[str copy];
|
||||||
|
}
|
||||||
|
END_TIMER;
|
||||||
|
PRINT_TIMER("NSString (10 copy) <@'ConstantString'> ");
|
||||||
|
|
||||||
|
str = [[NSString alloc] initWithCStringNoCopy: (char *)[str cString]
|
||||||
|
length: [str length]
|
||||||
|
freeWhenDone: NO];
|
||||||
|
START_TIMER;
|
||||||
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
{
|
||||||
|
[str copy];
|
||||||
|
}
|
||||||
|
END_TIMER;
|
||||||
|
PRINT_TIMER("NSString (10 copy) <NoCopy:free:NO> ");
|
||||||
|
|
||||||
|
str = [[NSString alloc] initWithCStringNoCopy: (char *)[str cString]
|
||||||
|
length: [str length]
|
||||||
|
freeWhenDone: YES];
|
||||||
|
START_TIMER;
|
||||||
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
{
|
||||||
|
[str copy];
|
||||||
|
}
|
||||||
|
END_TIMER;
|
||||||
|
PRINT_TIMER("NSString (10 copy) <NoCopy:free:YES> ");
|
||||||
|
|
||||||
|
str = [stringClass stringWithCString: "hello world"];
|
||||||
|
START_TIMER;
|
||||||
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
{
|
||||||
|
[str hash];
|
||||||
|
}
|
||||||
|
END_TIMER;
|
||||||
|
PRINT_TIMER("NSString (10 hash) <initWithCString:> ");
|
||||||
|
|
||||||
|
str = @"ConstantString";
|
||||||
|
START_TIMER;
|
||||||
|
for (i = 0; i < MAX_COUNT*10; i++)
|
||||||
|
{
|
||||||
|
[str hash];
|
||||||
|
}
|
||||||
|
END_TIMER;
|
||||||
|
PRINT_TIMER("NSString (10 hash) <@'ConstantString'> ");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT/100; i++)
|
for (i = 0; i < MAX_COUNT/100; i++)
|
||||||
|
@ -432,7 +489,7 @@ bench_str()
|
||||||
[arp release];
|
[arp release];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1/100 mkplist) ");
|
PRINT_TIMER("NSString (1/100 mkplist) \t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT/1000; i++)
|
for (i = 0; i < MAX_COUNT/1000; i++)
|
||||||
|
@ -440,7 +497,7 @@ bench_str()
|
||||||
[plstr propertyList];
|
[plstr propertyList];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1/1000 plparse)");
|
PRINT_TIMER("NSString (1/1000 plparse)\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT/1000; i++)
|
for (i = 0; i < MAX_COUNT/1000; i++)
|
||||||
|
@ -455,7 +512,7 @@ bench_str()
|
||||||
[arp release];
|
[arp release];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1/1000 plcomp)");
|
PRINT_TIMER("NSString (1/1000 plcomp)\t\t");
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
for (i = 0; i < MAX_COUNT/100; i++)
|
for (i = 0; i < MAX_COUNT/100; i++)
|
||||||
|
@ -464,7 +521,7 @@ bench_str()
|
||||||
[des deserializePropertyListFromData: d mutableContainers: NO];
|
[des deserializePropertyListFromData: d mutableContainers: NO];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1/100 ser/des)");
|
PRINT_TIMER("NSString (1/100 ser/des)\t\t");
|
||||||
|
|
||||||
[NSDeserializer uniquing: YES];
|
[NSDeserializer uniquing: YES];
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -474,7 +531,7 @@ bench_str()
|
||||||
[des deserializePropertyListFromData: d mutableContainers: NO];
|
[des deserializePropertyListFromData: d mutableContainers: NO];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1/100 ser/des - uniquing)");
|
PRINT_TIMER("NSString (1/100 ser/des - uniquing)\t");
|
||||||
[NSDeserializer uniquing: NO];
|
[NSDeserializer uniquing: NO];
|
||||||
|
|
||||||
START_TIMER;
|
START_TIMER;
|
||||||
|
@ -484,7 +541,7 @@ bench_str()
|
||||||
[una unarchiveObjectWithData: d];
|
[una unarchiveObjectWithData: d];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSString (1/100 arc/una)");
|
PRINT_TIMER("NSString (1/100 arc/una)\t\t");
|
||||||
|
|
||||||
AUTO_END;
|
AUTO_END;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +565,7 @@ bench_date()
|
||||||
[d release];
|
[d release];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSCalendarDate (various)");
|
PRINT_TIMER("NSCalendarDate (various)\t\t");
|
||||||
AUTO_END;
|
AUTO_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +590,7 @@ bench_data()
|
||||||
[d release];
|
[d release];
|
||||||
}
|
}
|
||||||
END_TIMER;
|
END_TIMER;
|
||||||
PRINT_TIMER("NSData (various)");
|
PRINT_TIMER("NSData (various)\t\t\t");
|
||||||
AUTO_END;
|
AUTO_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +610,7 @@ int main(int argc, char *argv[], char **env)
|
||||||
stringClass = [NSString class];
|
stringClass = [NSString class];
|
||||||
|
|
||||||
pool = [NSAutoreleasePool new];
|
pool = [NSAutoreleasePool new];
|
||||||
printf(" Test \t time (sec) \t index\n");
|
printf(" Test \t\t\t\t time (sec) \t index\n");
|
||||||
bench_object();
|
bench_object();
|
||||||
bench_str();
|
bench_str();
|
||||||
bench_array();
|
bench_array();
|
||||||
|
|
175
Testing/exported-strings.m
Normal file
175
Testing/exported-strings.m
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
/** externs.m Program to test correct initialization of externs.
|
||||||
|
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: David Ayers <d.ayers@inode.at>
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#define MyAssert1(IDENT) do { \
|
||||||
|
cache[i++] = IDENT; \
|
||||||
|
assert (IDENT != 0); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define MyAssert2(IDENT) do { \
|
||||||
|
NSCAssert2([IDENT isEqual: \
|
||||||
|
[NSString stringWithCString: #IDENT]], \
|
||||||
|
@"Invalid value: %@ for: %s", \
|
||||||
|
IDENT, #IDENT); \
|
||||||
|
NSCAssert2([cache[i++] isEqual: IDENT], \
|
||||||
|
@"Initial values differ:%@ %@", \
|
||||||
|
cache[i-1], IDENT); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define CACHE_SIZE 256
|
||||||
|
NSString *cache[CACHE_SIZE];
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/* Insure extern identifiers are initialized
|
||||||
|
before ObjC code is executed. */
|
||||||
|
MyAssert1(NSConnectionDidDieNotification);
|
||||||
|
MyAssert1(NSConnectionDidInitializeNotification);
|
||||||
|
MyAssert1(NSWillBecomeMultiThreadedNotification);
|
||||||
|
MyAssert1(NSThreadDidStartNotification);
|
||||||
|
MyAssert1(NSThreadWillExitNotification);
|
||||||
|
// MyAssert1(PortBecameInvalidNotification);
|
||||||
|
// MyAssert1(InPortClientBecameInvalidNotification);
|
||||||
|
// MyAssert1(InPortAcceptedClientNotification);
|
||||||
|
MyAssert1(NSPortDidBecomeInvalidNotification);
|
||||||
|
MyAssert1(NSConnectionReplyMode);
|
||||||
|
MyAssert1(NSBundleDidLoadNotification);
|
||||||
|
MyAssert1(NSShowNonLocalizedStrings);
|
||||||
|
MyAssert1(NSLoadedClasses);
|
||||||
|
// MyAssert1(StreamException);
|
||||||
|
MyAssert1(NSArgumentDomain);
|
||||||
|
MyAssert1(NSGlobalDomain);
|
||||||
|
MyAssert1(NSRegistrationDomain);
|
||||||
|
MyAssert1(NSUserDefaultsDidChangeNotification);
|
||||||
|
MyAssert1(NSWeekDayNameArray);
|
||||||
|
MyAssert1(NSShortWeekDayNameArray);
|
||||||
|
MyAssert1(NSMonthNameArray);
|
||||||
|
MyAssert1(NSShortMonthNameArray);
|
||||||
|
MyAssert1(NSTimeFormatString);
|
||||||
|
MyAssert1(NSDateFormatString);
|
||||||
|
MyAssert1(NSShortDateFormatString);
|
||||||
|
MyAssert1(NSTimeDateFormatString);
|
||||||
|
MyAssert1(NSShortTimeDateFormatString);
|
||||||
|
MyAssert1(NSCurrencySymbol);
|
||||||
|
MyAssert1(NSDecimalSeparator);
|
||||||
|
MyAssert1(NSThousandsSeparator);
|
||||||
|
MyAssert1(NSInternationalCurrencyString);
|
||||||
|
MyAssert1(NSCurrencyString);
|
||||||
|
// MyAssert1(NSNegativeCurrencyFormatString);
|
||||||
|
// MyAssert1(NSPositiveCurrencyFormatString);
|
||||||
|
MyAssert1(NSDecimalDigits);
|
||||||
|
MyAssert1(NSAMPMDesignation);
|
||||||
|
MyAssert1(NSHourNameDesignations);
|
||||||
|
MyAssert1(NSYearMonthWeekDesignations);
|
||||||
|
MyAssert1(NSEarlierTimeDesignations);
|
||||||
|
MyAssert1(NSLaterTimeDesignations);
|
||||||
|
MyAssert1(NSThisDayDesignations);
|
||||||
|
MyAssert1(NSNextDayDesignations);
|
||||||
|
MyAssert1(NSNextNextDayDesignations);
|
||||||
|
MyAssert1(NSPriorDayDesignations);
|
||||||
|
MyAssert1(NSDateTimeOrdering);
|
||||||
|
MyAssert1(NSLanguageCode);
|
||||||
|
MyAssert1(NSLanguageName);
|
||||||
|
MyAssert1(NSFormalName);
|
||||||
|
MyAssert1(NSLocale);
|
||||||
|
MyAssert1(NSConnectionRepliesReceived);
|
||||||
|
MyAssert1(NSConnectionRepliesSent);
|
||||||
|
MyAssert1(NSConnectionRequestsReceived);
|
||||||
|
MyAssert1(NSConnectionRequestsSent);
|
||||||
|
MyAssert1(NSConnectionLocalCount);
|
||||||
|
MyAssert1(NSConnectionProxyCount);
|
||||||
|
MyAssert1(NSClassDescriptionNeededForClassNotification);
|
||||||
|
|
||||||
|
assert(i < CACHE_SIZE); /* incread the cache size. */
|
||||||
|
|
||||||
|
[NSAutoreleasePool enableDoubleReleaseCheck:YES];
|
||||||
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
MyAssert2(NSConnectionDidDieNotification);
|
||||||
|
MyAssert2(NSConnectionDidInitializeNotification);
|
||||||
|
MyAssert2(NSWillBecomeMultiThreadedNotification);
|
||||||
|
MyAssert2(NSThreadDidStartNotification);
|
||||||
|
MyAssert2(NSThreadWillExitNotification);
|
||||||
|
// MyAssert2(PortBecameInvalidNotification);
|
||||||
|
// MyAssert2(InPortClientBecameInvalidNotification);
|
||||||
|
// MyAssert2(InPortAcceptedClientNotification);
|
||||||
|
MyAssert2(NSPortDidBecomeInvalidNotification);
|
||||||
|
MyAssert2(NSConnectionReplyMode);
|
||||||
|
MyAssert2(NSBundleDidLoadNotification);
|
||||||
|
MyAssert2(NSShowNonLocalizedStrings);
|
||||||
|
MyAssert2(NSLoadedClasses);
|
||||||
|
MyAssert2(NSArgumentDomain);
|
||||||
|
MyAssert2(NSGlobalDomain);
|
||||||
|
MyAssert2(NSRegistrationDomain);
|
||||||
|
MyAssert2(NSUserDefaultsDidChangeNotification);
|
||||||
|
MyAssert2(NSWeekDayNameArray);
|
||||||
|
MyAssert2(NSShortWeekDayNameArray);
|
||||||
|
MyAssert2(NSMonthNameArray);
|
||||||
|
MyAssert2(NSShortMonthNameArray);
|
||||||
|
MyAssert2(NSTimeFormatString);
|
||||||
|
MyAssert2(NSDateFormatString);
|
||||||
|
MyAssert2(NSShortDateFormatString);
|
||||||
|
MyAssert2(NSTimeDateFormatString);
|
||||||
|
MyAssert2(NSShortTimeDateFormatString);
|
||||||
|
MyAssert2(NSCurrencySymbol);
|
||||||
|
MyAssert2(NSDecimalSeparator);
|
||||||
|
MyAssert2(NSThousandsSeparator);
|
||||||
|
MyAssert2(NSInternationalCurrencyString);
|
||||||
|
MyAssert2(NSCurrencyString);
|
||||||
|
// MyAssert2(NSNegativeCurrencyFormatString);
|
||||||
|
// MyAssert2(NSPositiveCurrencyFormatString);
|
||||||
|
MyAssert2(NSDecimalDigits);
|
||||||
|
MyAssert2(NSAMPMDesignation);
|
||||||
|
MyAssert2(NSHourNameDesignations);
|
||||||
|
MyAssert2(NSYearMonthWeekDesignations);
|
||||||
|
MyAssert2(NSEarlierTimeDesignations);
|
||||||
|
MyAssert2(NSLaterTimeDesignations);
|
||||||
|
MyAssert2(NSThisDayDesignations);
|
||||||
|
MyAssert2(NSNextDayDesignations);
|
||||||
|
MyAssert2(NSNextNextDayDesignations);
|
||||||
|
MyAssert2(NSPriorDayDesignations);
|
||||||
|
MyAssert2(NSDateTimeOrdering);
|
||||||
|
MyAssert2(NSLanguageCode);
|
||||||
|
MyAssert2(NSLanguageName);
|
||||||
|
MyAssert2(NSFormalName);
|
||||||
|
MyAssert2(NSLocale);
|
||||||
|
MyAssert2(NSConnectionRepliesReceived);
|
||||||
|
MyAssert2(NSConnectionRepliesSent);
|
||||||
|
MyAssert2(NSConnectionRequestsReceived);
|
||||||
|
MyAssert2(NSConnectionRequestsSent);
|
||||||
|
MyAssert2(NSConnectionLocalCount);
|
||||||
|
MyAssert2(NSConnectionProxyCount);
|
||||||
|
MyAssert2(NSClassDescriptionNeededForClassNotification);
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue