Alois-xx / SerializerTests

.NET Serializer testing framework
76 stars 22 forks source link

Add Known Types To SlimSerializer. #1

Closed itadapter closed 7 years ago

itadapter commented 7 years ago

If I am not mistaken the Wire serializer can benefit from the similar approach.

Also, the very beneficial test case would have been: create an object and serilize it many times into stream, not 1 huge object, but 1 small i.e. with 5-10 fields (like a business message) and write it to stream 50,000 times etc..

This is a typical case used in networking/service apps.

Slim has special optimization for it called Batching - I have added a comment for that

Alois-xx commented 7 years ago

Looks good to me. If there are significant changes in the performance I will create two test classes to show the influence of serializer settings on performance.

Alois-xx commented 7 years ago

The timing did not really change and the serialized size did drop by 559 bytes. I think that the known types thing is certainly helpful for network but if you are reading a large stream then the skipping of the header describing the types does not make a big difference. My test is more stress test in a not so widely used field where large messages are not dominant but can happen. If the serializer scales nicely compared to small messages all is ok but as the example of BinaryFormatter has shown even the .NET Framework was only tested with small data sizes which did certainly cause issues in some applications which did become much slower because the serialized data needed to be become big enough to show the issue.