Posted by: sbelus | 28/03/2014

Serialization – testing performance

Lately I was looking for optimal solution for object serialization in .NET. Optimal means:

  • small size of serialized data
  • fast serialization & deserialization for 50000 objects
  • serialized data should be human-readable

I found some .NET implementations for json & yaml serialization which I have tested:

Before I setup the test procedure I did some pre-test and YamlSerializer didn’t show the good side. It was the slowest and for some objects it throws an exception while for the same object other serializers work fine. It was probably configuration issue, however I didn’t spend additional time to solve it as I saw that other are better.

Test procedure

For tests I used an entity with nested list of other entity. As a whole it was not a big object, however it contain: ~50 string fields, 15 decimal, 10 boolean, 6 DateTime and 6 integers. All the results were compared to standard XmlSerializer.

Size of serialized data

The following graph shows total amount of the serialized data:

SerializationSize

As you can see Json & Yaml serialization has very similar size. That is not a surprise, if we look on the format of both standards. All sizes are almost 50% (in this case) smaller in compare to XmlSerializer.

Time performance

First test (1000 rounds of serialization) pointed out that only three of serializers can be used on bigger test.

SerializationTime1

Time of YamlDotNet deserialization is totally unacceptable. It took over 20 seconds, while other did their work in miliseconds (XmlSerializer, Json.Net & ServceStack) or took about 3 seconds (JsonUtilities)

For 50000 rounds of serialization JsonUtilities took over 2 minutes so it won’t be shown on the screen below :

SerializationTime2

As you can see other serializers were far much better than JsonUtilities (CodeFluent Runtime Client). There is also no big different between commercial serializer (ServiceStack) and based on MIT license – Json.Net. ServiceStack is faster, but in this case the difference is less than one second on serializing and a little above 1 second  when deserializing. XmlSerializer is also fast, however it does not meet my size goal.

 

Advertisements

Responses

  1. Hi, can you post your reproducing benchmark on CodeFluent’s forums or send us a support email so we can see if we can improve things up? Thanks. SoftFluent Support.

  2. Hi, I sent you a link to the code via email. I’m happy to hear that you are concerned about those results. I’m looking forward to test it again if you make some performance enhancements in your product or show me the error I’ve made. Please let me know.

  3. Hi,
    Came by this post again. Just for you to know we’ve vastly improved JsonUtilities performance in april 2015 (version 818 and higher). It should be comparable to others now.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: