Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/aspnet/MessagePack-CSharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/SerializerBenchmark/Serializers/ProtobufNetSerializer.cs')
-rw-r--r--benchmark/SerializerBenchmark/Serializers/ProtobufNetSerializer.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/benchmark/SerializerBenchmark/Serializers/ProtobufNetSerializer.cs b/benchmark/SerializerBenchmark/Serializers/ProtobufNetSerializer.cs
new file mode 100644
index 00000000..7b44b5a7
--- /dev/null
+++ b/benchmark/SerializerBenchmark/Serializers/ProtobufNetSerializer.cs
@@ -0,0 +1,33 @@
+// Copyright (c) All contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.IO;
+using ProtoBuf;
+
+namespace Benchmark.Serializers
+{
+ public class ProtobufNetSerializer : SerializerBase
+ {
+ public override T Deserialize<T>(object input)
+ {
+ using (var ms = new MemoryStream((byte[])input))
+ {
+ return Serializer.Deserialize<T>(ms);
+ }
+ }
+
+ public override object Serialize<T>(T input)
+ {
+ using (var ms = new MemoryStream())
+ {
+ Serializer.Serialize(ms, input);
+ return ms.ToArray();
+ }
+ }
+
+ public override string ToString()
+ {
+ return "ProtobufNet";
+ }
+ }
+}