Skip to content

Commit

Permalink
added output of serialized data sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
BYTEPOETS-MBR committed Mar 9, 2011
1 parent 2ed5440 commit 02bde61
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 19 deletions.
7 changes: 7 additions & 0 deletions Classes/AppleBinaryPlistBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
return [NSPropertyListSerialization dataFromPropertyList:self.collection
format:NSPropertyListBinaryFormat_v1_0
errorDescription:NULL].length;
}

@end
6 changes: 6 additions & 0 deletions Classes/AppleJSONBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
return [[JSON stringWithObject:self.collection options:0 error:nil] length];
}


@end
8 changes: 8 additions & 0 deletions Classes/AppleXMLPlistBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
return [NSPropertyListSerialization dataFromPropertyList:self.collection
format:NSPropertyListXMLFormat_v1_0
errorDescription:NULL].length;
}


@end
1 change: 1 addition & 0 deletions Classes/BenchmarkTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void bench(NSString *what, NSString *direction, void (^block)(void), NSDictionar
@protocol BenchmarkTestProtocol
- (NSDictionary *)runBenchmarkReading;
- (NSDictionary *)runBenchmarkWriting;
- (NSUInteger)serializedSize;

@property (readonly) NSString *benchmarkName;
@end
Expand Down
40 changes: 21 additions & 19 deletions Classes/BenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ + (void)runBenchmarksWithCollection:(id)theCollection
[BenchmarkProgressViewController instance].benchmarkDirectionLabel.text = @"reading";
});
readingResult = [benchmarkObject runBenchmarkReading];
if (readingResult != nil)
{
[readingResults addObject:readingResult];
}
else
{
NSLog(@"%@\tread\tERROR: missing benchmark results", benchmarkObject.benchmarkName);
}

}

NSDictionary *writingResult = nil;
Expand All @@ -215,25 +224,18 @@ + (void)runBenchmarksWithCollection:(id)theCollection
[BenchmarkProgressViewController instance].benchmarkDirectionLabel.text = @"writing";
});
writingResult = [benchmarkObject runBenchmarkWriting];
}

if (writingResult != nil)
{
[writingResults addObject:writingResult];
}
else
{
NSLog(@"%@\twrite\tERROR: missing benchmark results", benchmarkObject.benchmarkName);
}

if (readingResult != nil)
{
[readingResults addObject:readingResult];
}
else
{
NSLog(@"%@\tread\tERROR: missing benchmark results", benchmarkObject.benchmarkName);
}
NSUInteger serializedSize = [benchmarkObject serializedSize];
NSLog(@"%@\tsize:\t%u",benchmarkObject.benchmarkName,serializedSize);
if (writingResult != nil)
{
[writingResults addObject:writingResult];
}
else
{
NSLog(@"%@\twrite\tERROR: missing benchmark results", benchmarkObject.benchmarkName);
}

}
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions Classes/JSONFrameworkBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
SBJsonWriter *sbjsonWriter = [[SBJsonWriter new] autorelease];
return [sbjsonWriter dataWithObject:self.collection].length;
}


@end
4 changes: 4 additions & 0 deletions Classes/JSONKitBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
return [self.collection JSONString].length;
}

@end
7 changes: 7 additions & 0 deletions Classes/TouchJSONBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
CJSONSerializer *cjsonSerializer = [CJSONSerializer serializer];
return [cjsonSerializer serializeArray:self.collection error:nil].length;
}


@end
5 changes: 5 additions & 0 deletions Classes/YAJLBenchmarkTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ - (NSDictionary *)runBenchmarkWriting
return writingResult;
}

- (NSUInteger)serializedSize
{
return [self.collection yajl_JSONString].length;
}


@end

0 comments on commit 02bde61

Please sign in to comment.