Serialize/Deserialize Performance

Is there a way to optimize the size and speed of serialization of objects?

  1. Create 20,000 TestNode objects
  2. Serialize → 53,800KB file <<<<<<< It’s too big
  3. Deserialize → 69,181 ms <<<<<<< Tooooo~ slow

※ Logic objects in real projects are much more complex.
※ At least 10000 objects are managed for each document.

[Serializable]
public class TestNode : GoNode
{
    public TestNode()
    {
        var r = new GoRectangle()
        {
            Selectable = false,
            BrushColor = Color.Red,
            Bounds = new RectangleF(0, 0, 200, 200)
        };

        this.Add(r);

        for (var i = 0; i < 9; i++)
        {
            var text = new GoText()
            {
                Location = new Point(10, 5 + (i * 20)),
                Text = $"Test - {i + 1}",
            };

            this.Add(text);

            var port = new GoPort()
            {
                Location = new Point(10 - 7, 5 + (i * 20)),
            };

            this.Add(port);
        }
    }
}

Are you using binary or GoXml serialization?

Using binary.

Analyzing FunctionBlock45 example currently…

Is GoXml generally more efficient than Binary?


FunctionBlock Example XML vs Binary
XML
16.0MB
Load time : 4.296 s

Binary
62.8MB
Load time : 86.098 s

When dealing with many objects, it is considered right to use GoXml.

I don’t think I can easily apply GoXml to my project at this point.

Thanks anyway~

Well, you’ve just done a more complete test to compare the 2 than I’ve ever done, but your results confirm what I was expecting to be the case. We have always discouraged users from using binary.

Note that Binary serialization has been removed from .Net Core if you go that way.