From 4dc0dfb1546998b15a5e98d5dde6154d463365f2 Mon Sep 17 00:00:00 2001 From: csharptest Date: Fri, 10 Jun 2011 18:01:34 -0500 Subject: Added initial DictionaryReader/Writer implementations --- src/ProtoBench/Program.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/ProtoBench/Program.cs') diff --git a/src/ProtoBench/Program.cs b/src/ProtoBench/Program.cs index 2239fe08..34860f33 100644 --- a/src/ProtoBench/Program.cs +++ b/src/ProtoBench/Program.cs @@ -137,6 +137,10 @@ namespace Google.ProtocolBuffers.ProtoBench new JsonFormatWriter(temp).WriteMessage(sampleMessage); string jsonMessageText = temp.ToString(); + IDictionary dictionary = new Dictionary(StringComparer.Ordinal); + new DictionaryWriter(dictionary).WriteMessage(sampleMessage); + + //Serializers if(!FastTest) RunBenchmark("Serialize to byte string", inputData.Length, () => sampleMessage.ToByteString()); RunBenchmark("Serialize to byte array", inputData.Length, () => sampleMessage.ToByteArray()); @@ -145,6 +149,7 @@ namespace Google.ProtocolBuffers.ProtoBench RunBenchmark("Serialize to xml", xmlMessageText.Length, () => new XmlFormatWriter(new StringWriter()).WriteMessage(sampleMessage)); RunBenchmark("Serialize to json", jsonMessageText.Length, () => new JsonFormatWriter(new StringWriter()).WriteMessage(sampleMessage)); + RunBenchmark("Serialize to dictionary", sampleMessage.SerializedSize, () => new DictionaryWriter().WriteMessage(sampleMessage)); //Deserializers if (!FastTest) RunBenchmark("Deserialize from byte string", inputData.Length, @@ -168,6 +173,7 @@ namespace Google.ProtocolBuffers.ProtoBench RunBenchmark("Deserialize from xml", xmlMessageText.Length, () => new XmlFormatReader(xmlMessageText).Merge(defaultMessage.WeakCreateBuilderForType()).WeakBuild()); RunBenchmark("Deserialize from json", jsonMessageText.Length, () => new JsonFormatReader(jsonMessageText).Merge(defaultMessage.WeakCreateBuilderForType()).WeakBuild()); + RunBenchmark("Deserialize from dictionary", sampleMessage.SerializedSize, () => new DictionaryReader(dictionary).Merge(defaultMessage.WeakCreateBuilderForType()).WeakBuild()); Console.WriteLine(); return true; -- cgit v1.2.3