Poco.md

February 9, 2020 ยท View on GitHub

Pocos

Protobuf-net 3.0.0-alpha.43 / MessagePack 2.0.335 / NetSerializer 4.1.1 / Ceras 4.1.7 / Apex

Serializing/deserializing a list of 1000 small pocos defined as follows

        public sealed class ImmutablePoco
        {
            public ImmutablePoco(string s, int i, Guid g, DateTime d)
            {
                StringProp = s;
                IntProp = i;
                GuidProp = g;
                DateProp = d;
            }
            public readonly string StringProp;      //using the text "hello"
            public readonly int IntProp;            //123
            public readonly Guid GuidProp;          //Guid.NewGuid()
            public readonly DateTime DateProp;      //DateTime.Now
        }

        public class Poco
        {
            public string StringProp { get; set; }      //using the text "hello"
            public int IntProp { get; set; }            //123
            public Guid GuidProp { get; set; }          //Guid.NewGuid()
            public DateTime DateProp { get; set; }      //DateTime.Now
        }
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18362
Intel Core i5-4690 CPU 3.50GHz (Haswell), 1 CPU, 4 logical and 4 physical cores
.NET Core SDK=3.1.101
  [Host]     : .NET Core 3.1.1 (CoreCLR 4.700.19.60701, CoreFX 4.700.19.60801), X64 RyuJIT

Mutable Poco Serialization

MethodMeanErrorStdDevRatioRatioSDGen 0Gen 1Gen 2Allocated
Protobuf473.50 us6.492 us6.073 us36.350.45---314 B
NetSerializer420.98 us1.721 us1.437 us32.360.10----
MessagePack372.67 us1.011 us0.945 us28.660.12---1 B
Ceras264.49 us0.912 us0.853 us20.340.09---40 B
Apex13.01 us0.035 us0.031 us1.000.00----

Mutable Poco Deserialization

MethodMeanErrorStdDevRatioRatioSDGen 0Gen 1Gen 2Allocated
Protobuf598.17 us2.484 us2.324 us21.090.136.83590.9766-105.44 KB
NetSerializer455.12 us0.960 us0.898 us16.050.106.34770.9766-93.99 KB
MessagePack451.09 us2.873 us2.687 us15.920.126.34770.4883-93.81 KB
Ceras313.05 us0.756 us0.670 us11.040.086.34770.4883-93.81 KB
Apex28.35 us0.201 us0.178 us1.000.006.74441.0071-93.99 KB

Immutable Poco Serialization

MethodMeanErrorStdDevRatioRatioSDGen 0Gen 1Gen 2Allocated
Protobuf459.12 us1.416 us1.325 us33.490.13---314 B
NetSerializer423.13 us1.436 us1.343 us30.860.14----
MessagePack366.59 us0.828 us0.775 us26.740.07---1 B
Ceras250.09 us0.995 us0.931 us18.240.08---41 B
Apex13.71 us0.029 us0.027 us1.000.00----

Immutable Poco Deserialization

MethodMeanErrorStdDevRatioRatioSDGen 0Gen 1Gen 2Allocated
Protobuf627.17 us2.944 us2.609 us21.560.116.8359--105.44 KB
NetSerializer450.55 us1.444 us1.280 us15.490.086.34770.4883-93.99 KB
MessagePack453.53 us0.936 us0.830 us15.590.056.34770.4883-93.81 KB
Ceras593.53 us2.421 us2.147 us20.400.1111.71880.9766-171.93 KB
Apex29.09 us0.123 us0.109 us1.000.006.74440.8850-93.99 KB