Top 5 Fastest WCF Serializers

Recently have been using WCF again at work, I wondered how slow (or fast) the latest DataContractSerailizer is. I was pleasantly surprised that it was fairly similar in speed to the JSon Serializer.



I have run some benchmarks and run speed tests on the following 5 serializers:


This is the default WCF serializer and is used by specifying the DataContract and DataMember attributes on your classes such as the following:

public class DtoDataContract : IDataContract
    public long Id { get; set; }

    public string Name { get; set; }

    public string Description { get; set; }

    // Other Members

This generates XML with each Class and Field as Tags, such as the following:

<DtoDataContract i:type="ArrayOfDtoDataContract" xmlns="" xmlns:i="">
        <Description>Open-architected responsive service-desk</Description>
        <Name>Bernier Group</Name>

Size: 473 Bytes


This is an alternative Serializer that comes out of the box with WCF, and it is very similar to DataContractSerializer but adds additional information to each tag that can be used by the client.

This serializer generates the following output:

<ArrayOfDtoDataContract z:Id="1" z:Type="System.Collections.Generic.List`1[[Benchmark.DtoDataContract, Benchmark, Version=, Culture=neutral, PublicKeyToken=null]]" z:Assembly="0" xmlns="" xmlns:i="" xmlns:z="">
    <_items z:Id="2" z:Size="4">
        <DtoDataContract z:Id="3">
            <Description z:Id="4">Open-architected responsive service-desk</Description>
            <Name z:Id="5">Bernier Group</Name>
        <DtoDataContract i:nil="true" />
        <DtoDataContract i:nil="true" />
        <DtoDataContract i:nil="true" />

Size: 874 Bytes


      "Name":"Bernier Group",
      "Description":"Open-architected responsive service-desk",

Size: 207 Bytes


I decided to compare Google ProtocalBuffers .NET implementation by Marc Gravell – protobufnet.

To use ProtoBuf, you need to decorate the class with ProtoContract and each member with ProtoMember(x) where x is the position of the field when serializing.

public class DtoDataContract : IDataContract
    public long Id { get; set; }

    public string Name { get; set; }

    public string Description { get; set; }

    // Other members

Result is Raw Binary Stream such as:

Bernier Group\u001a(Open-architected responsive service-desk"\u000b\u0008�Ũ����4\u0010\u0005*\u0006\u0008��\u0004\u0018\u00042\u0006\u0008��\u0001\u0018\u0004:\u0006\u0008��\u0003\u0018\u0004B\u0006\u0008�\u0001\u0018\u0004

Size: 104 B


This is a custom hand rolled BinaryWriter for my class using BinaryWriter and BinaryReader such as the following:


// Count of items in list to help deserialize

foreach (var item in _items)


var reader = new BinaryReader(stream);

var count = reader.ReadInt32();
var list = new List<DtoDataContract>(count);

while (stream.Position < stream.Length)
    var item = new DtoDataContract
        Id = reader.ReadInt64(),
        Balance = reader.ReadDecimal(),
        Description = reader.ReadString(),
        Interest = reader.ReadDecimal(),
        Transaction = reader.ReadDecimal(),
        Limit = reader.ReadDecimal(),
        Name = reader.ReadString(),
        Created = DateTime.FromBinary(reader.ReadInt64())


This produces a 30% longer binary stream than protobuf (surprisingly) but is faster

\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�\u001f\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000(Open-architected responsive service-desk��\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000�e\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000�Y\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000

Size: 139 B

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

This site uses Akismet to reduce spam. Learn how your comment data is processed.