Skip to content

Commit

Permalink
Fixed test compilation (needed a new header) and added timing test ou…
Browse files Browse the repository at this point in the history
…tput.
  • Loading branch information
AlanQuatermain committed May 16, 2009
1 parent 367b73a commit 3d954f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Test/ParserComparison/ParserComparison.m
Expand Up @@ -216,13 +216,15 @@ static void RunNSDocumentTest( NSURL * url )
fprintf( stdout, "Testing NSXMLDocument...\n" );

mach_vm_size_t start = GetProcessMemoryUsage();
CFAbsoluteTime time = CFAbsoluteTimeGetCurrent();
NSXMLDocument * doc = [[NSXMLDocument alloc] initWithContentsOfURL: url
options: NSXMLDocumentTidyXML
error: NULL];
time = CFAbsoluteTimeGetCurrent() - time;
mach_vm_size_t end = GetProcessMemoryUsage();
[doc release];

fprintf( stdout, "Peak VM usage: %s\n", MemorySizeString(end - start) );
fprintf( stdout, " %.02f seconds, peak VM usage: %s\n", time, MemorySizeString(end - start) );
}

static void RunNSParserTest( NSURL * url )
Expand All @@ -233,12 +235,14 @@ static void RunNSParserTest( NSURL * url )

fprintf( stdout, "Testing NSXMLParser from URL...\n" );

CFAbsoluteTime time = CFAbsoluteTimeGetCurrent();
delegate.startVMSize = GetProcessMemoryUsage();

(void) [parser parse];

fprintf( stdout, "Parsed %lu numbers\n", (unsigned long)[delegate.set count] );
fprintf( stdout, "Peak VM usage: %s\n", MemorySizeString(delegate.maxVMSize) );
time = CFAbsoluteTimeGetCurrent() - time;
fprintf( stdout, " Parsed %lu numbers\n", (unsigned long)[delegate.set count] );
fprintf( stdout, " %.02f seconds, peak VM usage: %s\n", time, MemorySizeString(delegate.maxVMSize) );

[delegate release];
[parser release];
Expand Down Expand Up @@ -267,12 +271,14 @@ static void RunMappedNSParserTest( NSURL * url )

fprintf( stdout, "Testing NSXMLParser with mapped data...\n" );

CFAbsoluteTime time = CFAbsoluteTimeGetCurrent();
delegate.startVMSize = GetProcessMemoryUsage();

(void) [parser parse];

fprintf( stdout, "Parsed %lu numbers\n", (unsigned long)[delegate.set count] );
fprintf( stdout, "Peak VM usage: %s\n", MemorySizeString(delegate.maxVMSize) );
time = CFAbsoluteTimeGetCurrent() - time;
fprintf( stdout, " Parsed %lu numbers\n", (unsigned long)[delegate.set count] );
fprintf( stdout, " %.02f seconds, peak VM usage: %s\n", time, MemorySizeString(delegate.maxVMSize) );

[delegate release];
[parser release];
Expand Down Expand Up @@ -302,12 +308,14 @@ static void RunAQParserTest( NSURL * url )

fprintf( stdout, "Testing AQXMLParser...\n" );

CFAbsoluteTime time = CFAbsoluteTimeGetCurrent();
delegate.startVMSize = GetProcessMemoryUsage();

(void) [parser parse];

fprintf( stdout, "Parsed %lu numbers\n", (unsigned long)[delegate.set count] );
fprintf( stdout, "Peak VM usage: %s\n", MemorySizeString(delegate.maxVMSize) );
time = CFAbsoluteTimeGetCurrent() - time;
fprintf( stdout, " Parsed %lu numbers\n", (unsigned long)[delegate.set count] );
fprintf( stdout, " %.02f seconds, peak VM usage: %s\n", time, MemorySizeString(delegate.maxVMSize) );

[parser release];
[delegate release];
Expand Down
Expand Up @@ -34,6 +34,7 @@
08FB7796FE84155DC02AAC07 /* ParserComparison.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ParserComparison.m; sourceTree = "<group>"; };
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32A70AAB03705E1F00C91783 /* ParserComparison_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserComparison_Prefix.pch; sourceTree = "<group>"; };
3824D5860FBF3A5F00F8E12D /* iPhoneNonatomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iPhoneNonatomic.h; path = ../../iPhoneNonatomic.h; sourceTree = SOURCE_ROOT; };
388BDEFC0F8AAD12004A22FD /* AQXMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AQXMLParser.h; sourceTree = "<group>"; };
388BDEFD0F8AAD12004A22FD /* AQXMLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AQXMLParser.m; sourceTree = "<group>"; };
388BDEFF0F8AAD5F004A22FD /* MemoryUsageLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryUsageLogger.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -74,6 +75,7 @@
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
3824D5860FBF3A5F00F8E12D /* iPhoneNonatomic.h */,
388BDEFB0F8AAD12004A22FD /* StreamingXMLParser */,
32A70AAB03705E1F00C91783 /* ParserComparison_Prefix.pch */,
08FB7796FE84155DC02AAC07 /* ParserComparison.m */,
Expand Down

0 comments on commit 3d954f2

Please sign in to comment.