Skip to content

Compression Mode

Michael Brown edited this page Dec 2, 2018 · 1 revision

To enable compression mode, enable it as an option when serializing:

var strings = new List<string>();
for(var i=0; i < 50000; i++)
  strings.Add(// random data);
var compressedBytes = strings.Serialize(SerializerOptions.Compact);
var restoredObject = compressedBytes.Deserialize<List<string>>(compressedBytes);

Compression mode uses LZ4 compression which offers significant size savings on large objects, and especially with objects containing lots of string data. Tests show savings up to 33:1 in data size on large objects.

Smaller objects may actually increase in size slightly (a few bytes) because of the additional header information LZ4 introduces. It will also slow down performance slightly, although LZ4 is very quick for compression.

Clone this wiki locally