mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
Added stuff to check encode/decode
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3139 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d2d5feb8ef
commit
0a885c78a7
1 changed files with 35 additions and 2 deletions
|
@ -1,6 +1,4 @@
|
|||
/* A demonstration of writing and reading with NSArchiver */
|
||||
// Fri Oct 23 03:02:04 MET DST 1998 dave@turbocat.de
|
||||
// cStringNoCopy -> cString
|
||||
|
||||
#if 1
|
||||
|
||||
|
@ -9,6 +7,7 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSUtilities.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -45,8 +44,12 @@ printf("%u\n", [arc retainCount]);
|
|||
[arc encodeRootObject: set];
|
||||
una = [[[NSUnarchiver alloc] initForReadingWithData: [arc archiverData]] autorelease];
|
||||
xxx = [una decodeObject];
|
||||
if ([xxx isEqual: set] == NO)
|
||||
printf("Argh\n");
|
||||
printf("%s\n", [[xxx description] cString]);
|
||||
[apl release];
|
||||
|
||||
|
||||
/* Write it to a file */
|
||||
[NSArchiver archiveRootObject: set toFile: @"./nsarchiver.dat"];
|
||||
|
||||
|
@ -73,6 +76,36 @@ printf("%u\n", [arc retainCount]);
|
|||
printf("%s\n", [o cString]);
|
||||
}
|
||||
|
||||
{
|
||||
NSDate *start = [NSDate date];
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
int i;
|
||||
NSUnarchiver *u = nil;
|
||||
NSArchiver *a = [NSArchiver new];
|
||||
|
||||
[NSAutoreleasePool enableDoubleReleaseCheck:NO];
|
||||
for (i = 0; i < 10000; i++) {
|
||||
NSMutableData *d;
|
||||
id o;
|
||||
|
||||
[a encodeRootObject: set];
|
||||
d = [a archiverData];
|
||||
if (u == nil) {
|
||||
u = [[NSUnarchiver alloc] initForReadingWithData: d];
|
||||
}
|
||||
else {
|
||||
[u resetUnarchiverWithData: d atIndex: 0];
|
||||
}
|
||||
o = [u decodeObject];
|
||||
[d setLength: 0];
|
||||
[a resetArchiver];
|
||||
}
|
||||
[a release];
|
||||
[u release];
|
||||
[arp release];
|
||||
printf("Time: %f\n", -[start timeIntervalSinceNow]);
|
||||
}
|
||||
|
||||
/* Do the autorelease. */
|
||||
[arp release];
|
||||
|
||||
|
|
Loading…
Reference in a new issue