本文介绍了快速,简单对象序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找最快的序列化方法的瓷砖在2D世界。可以说,这个世界很大,并因为电脑不能处理的同时加载多块,所以我分裂这个世界块。 的BinaryFormatter 似乎是缓慢的。有没有更快的方法,如何序列块对象?

WChunk对象结构

 公共类WChunk
{
    公众诠释ChunkX;
    公众诠释矮胖;
    公共SortedDictionary< WPoint,WTile>瓷砖;
}
 

WTile对象结构

 公共类WTile
{
    WPoint位置;
    INT数据;
}
 

解决方案

最快的选择,我知道的是 Protocol Buffers的

这里有一个性能比较(感谢@Andrei)

http://$c$c.google.com/p/protobuf-csharp-port/

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;
}
解决方案

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/

.NET implementations

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

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

这篇关于快速,简单对象序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:33