mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Various timezone updates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14606 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d8395dad43
commit
39aad49dd2
8 changed files with 571 additions and 417 deletions
|
@ -76,7 +76,7 @@ bench_object()
|
|||
START_TIMER;
|
||||
for (i = 0; i < MAX_COUNT*10; i++)
|
||||
{
|
||||
id i = [rootClass class];
|
||||
[rootClass class];
|
||||
}
|
||||
END_TIMER;
|
||||
baseline = [eTime timeIntervalSinceDate: sTime];
|
||||
|
@ -220,7 +220,7 @@ bench_object()
|
|||
START_TIMER;
|
||||
for (i = 0; i < MAX_COUNT*10; i++)
|
||||
{
|
||||
BOOL dummy = [rootClass instancesRespondToSelector: @selector(hash)];
|
||||
[rootClass instancesRespondToSelector: @selector(hash)];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("ObjC: 10 inst responds to sel");
|
||||
|
@ -341,7 +341,7 @@ bench_dict()
|
|||
|
||||
for (j = 0; j < 10; j++)
|
||||
{
|
||||
id dummy = [dict objectForKey: keys[i/10]];
|
||||
[dict objectForKey: keys[i/10]];
|
||||
}
|
||||
}
|
||||
END_TIMER;
|
||||
|
@ -350,7 +350,7 @@ bench_dict()
|
|||
START_TIMER;
|
||||
for (i = 0; i < MAX_COUNT*10; i++)
|
||||
{
|
||||
int dummy = [dict count];
|
||||
[dict count];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSDictionary (10 count)");
|
||||
|
@ -359,7 +359,7 @@ bench_dict()
|
|||
START_TIMER;
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
BOOL dummy = [dict isEqual: obj2];
|
||||
[dict isEqual: obj2];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSDict (ten times isEqual:)");
|
||||
|
@ -379,6 +379,7 @@ bench_str()
|
|||
Class des = [NSDeserializer class];
|
||||
Class md = [NSMutableDictionary class];
|
||||
|
||||
[[md new] release];
|
||||
AUTO_START;
|
||||
|
||||
plist = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
|
@ -418,7 +419,7 @@ bench_str()
|
|||
START_TIMER;
|
||||
for (i = 0; i < MAX_COUNT*10; i++)
|
||||
{
|
||||
int dummy = [str length];
|
||||
[str length];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSString (10 length) ");
|
||||
|
@ -427,7 +428,7 @@ bench_str()
|
|||
for (i = 0; i < MAX_COUNT/100; i++)
|
||||
{
|
||||
id arp = [NSAutoreleasePool new];
|
||||
NSString *s = [plist description];
|
||||
[plist description];
|
||||
[arp release];
|
||||
}
|
||||
END_TIMER;
|
||||
|
@ -436,7 +437,7 @@ bench_str()
|
|||
START_TIMER;
|
||||
for (i = 0; i < MAX_COUNT/1000; i++)
|
||||
{
|
||||
id p = [plstr propertyList];
|
||||
[plstr propertyList];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSString (1/1000 plparse)");
|
||||
|
@ -460,8 +461,7 @@ bench_str()
|
|||
for (i = 0; i < MAX_COUNT/100; i++)
|
||||
{
|
||||
NSData *d = [ser serializePropertyList: plist];
|
||||
id p = [des deserializePropertyListFromData: d
|
||||
mutableContainers: NO];
|
||||
[des deserializePropertyListFromData: d mutableContainers: NO];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSString (1/100 ser/des)");
|
||||
|
@ -471,8 +471,7 @@ bench_str()
|
|||
for (i = 0; i < MAX_COUNT/100; i++)
|
||||
{
|
||||
NSData *d = [ser serializePropertyList: plist];
|
||||
id p = [des deserializePropertyListFromData: d
|
||||
mutableContainers: NO];
|
||||
[des deserializePropertyListFromData: d mutableContainers: NO];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSString (1/100 ser/des - uniquing)");
|
||||
|
@ -482,7 +481,7 @@ bench_str()
|
|||
for (i = 0; i < MAX_COUNT/100; i++)
|
||||
{
|
||||
NSData *d = [arc archivedDataWithRootObject: plist];
|
||||
id p = [una unarchiveObjectWithData: d];
|
||||
[una unarchiveObjectWithData: d];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSString (1/100 arc/una)");
|
||||
|
@ -490,6 +489,29 @@ bench_str()
|
|||
AUTO_END;
|
||||
}
|
||||
|
||||
void
|
||||
bench_date()
|
||||
{
|
||||
int i;
|
||||
id d;
|
||||
AUTO_START;
|
||||
Class dateClass = [NSCalendarDate class];
|
||||
|
||||
printf("NSCalendarDate\n");
|
||||
START_TIMER;
|
||||
for (i = 0; i < MAX_COUNT/10; i++)
|
||||
{
|
||||
d = [[dateClass alloc] init];
|
||||
[d description];
|
||||
[d dayOfYear];
|
||||
[d minuteOfHour];
|
||||
[d release];
|
||||
}
|
||||
END_TIMER;
|
||||
PRINT_TIMER("NSCalendarDate (various)");
|
||||
AUTO_END;
|
||||
}
|
||||
|
||||
void
|
||||
bench_data()
|
||||
{
|
||||
|
@ -536,6 +558,7 @@ int main(int argc, char *argv[], char **env)
|
|||
bench_str();
|
||||
bench_array();
|
||||
bench_dict();
|
||||
bench_date();
|
||||
bench_data();
|
||||
AUTO_END;
|
||||
return 0;
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSUtilities.h>
|
||||
#include <Foundation/NSTimeZone.h>
|
||||
#include <Foundation/NSUtilities.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -36,7 +36,7 @@ main (int argc, char *argv[])
|
|||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
name = [NSString stringWithCString: argv[i]];
|
||||
name = [NSString stringWithUTF8String: argv[i]];
|
||||
zone = [NSTimeZone timeZoneWithName: name];
|
||||
if (zone != nil)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ main (int argc, char *argv[])
|
|||
[dict setObject: name forKey: [detail timeZoneAbbreviation]];
|
||||
e = [dict keyEnumerator];
|
||||
while ((abbrev = [e nextObject]) != nil)
|
||||
printf("%@\t%@\n", abbrev, name);
|
||||
printf("%s\t%s\n", [abbrev UTF8String], [name UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSUtilities.h>
|
||||
#include <Foundation/NSTimeZone.h>
|
||||
#include <Foundation/NSUtilities.h>
|
||||
|
||||
#define HOURSECS (60*60) /* Seconds in 1 hour. */
|
||||
#define DAYSECS (HOURSECS*24) /* Seconds in 24 hours. */
|
||||
|
@ -43,7 +43,7 @@ main (int argc, char *argv[])
|
|||
/* Obtain the regions for each latitudinal region. */
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
name = [NSString stringWithCString: argv[i]];
|
||||
name = [NSString stringWithUTF8String: argv[i]];
|
||||
zone = [NSTimeZone timeZoneWithName: name];
|
||||
if (zone != nil)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
e = [zones[i] objectEnumerator];
|
||||
while ((name = [e nextObject]) != nil)
|
||||
printf("%d %@\n", i, name);
|
||||
printf("%d %s\n", i, [name UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSTimeZone.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
id detail;
|
||||
|
||||
NSLog(@"time zones:\n%@\n", [[NSTimeZone timeZoneArray] description]);
|
||||
NSLog(@"time zones for PST:\n%@\n",
|
||||
[[[NSTimeZone abbreviationMap] objectForKey: @"PST"] description]);
|
||||
NSLog(@"local time zone:\n%@\n", [[NSTimeZone localTimeZone] description]);
|
||||
|
||||
[pool release];
|
||||
printf("time zones for PST:\n%s\n",
|
||||
[[[[NSTimeZone abbreviationMap] objectForKey: @"PST"] description] UTF8String]);
|
||||
printf("time zones:\n%s\n",
|
||||
[[[NSTimeZone timeZoneArray] description] UTF8String]);
|
||||
printf("local time zone:\n%s\n",
|
||||
[[[NSTimeZone localTimeZone] description] UTF8String]);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue