Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast simple object serialization

I am looking for fastest serialization method tiles in 2D world. Lets say the world is big and because computer can't handle that much blocks loaded at the same time, so I splitted the world to chunks. BinaryFormatter seems to be slow. Is there any faster method, how to serialize the chunk object?

WChunk object structure

public class WChunk
{
    public int ChunkX;
    public int ChunkY;
    public SortedDictionary<WPoint, WTile> Tiles;
}

WTile object structure

public class WTile
{
    WPoint Location;
    int Data;
}
like image 523
Matej Kormuth Avatar asked Jul 18 '12 21:07

Matej Kormuth


People also ask

What is serializing and Deserializing in Python?

Object serialization is the process of converting state of an object into byte stream. This byte stream can further be stored in any file-like object such as a disk file or memory stream. It can also be transmitted via sockets etc. Deserialization is the process of reconstructing the object from the byte stream.

What is serializing a model?

Serialization refers to the process of converting a data object (e.g., Python objects, Tensorflow models) into a format that allows us to store or transmit the data and then recreate the object when needed using the reverse process of deserialization.


1 Answers

The fastest option I'm aware of is Protocol Buffers.

There is a performance comparison here (thanks @Andrei)

http://theburningmonk.com/2011/08/performance-test-binaryformatter-vs-protobuf-net/

enter image description here

.NET implementations

http://code.google.com/p/protobuf-net/

http://code.google.com/p/protobuf-csharp-port/

like image 94
Eric J. Avatar answered Oct 17 '22 05:10

Eric J.