Salar.Bois
3.2.0
See the version list below for details.
dotnet add package Salar.Bois --version 3.2.0
NuGet\Install-Package Salar.Bois -Version 3.2.0
<PackageReference Include="Salar.Bois" Version="3.2.0" />
paket add Salar.Bois --version 3.2.0
#r "nuget: Salar.Bois, 3.2.0"
// Install Salar.Bois as a Cake Addin #addin nuget:?package=Salar.Bois&version=3.2.0 // Install Salar.Bois as a Cake Tool #tool nuget:?package=Salar.Bois&version=3.2.0
Salar.Bois is the most compact, extermly fast binary serializer for .Net Standard, .NET Code and .NET Framework.
- No compression is done, the high compact ratio is the result of Bois format.
- No configuration.
- No change to your classes.
- Compression is provided as a seperate package.
Why Salar.Bois?
- Because payload size matters. Bois serializer generates the smallest payload size.
- Because speed matters. Both serialization and deserialization are extremely fast.
- Easy to use,
Serialize<T>
andDeserialize<T>
are all you need. - No configuration required. No separate schema required.
NuGet Package
PM> Install-Package Salar.Bois
LZ4 Compression wrapper package
PM> Install-Package Salar.Bois.LZ4
Minimum frameworks supported are .Net Core 2.0, .Net Standard 2.1 and .Net Framework 4.5
Getting Started:
It is easy to use , just add the package to your project and voila, you can now use it.
All you need to do is to call Serialize
method.
BoisSerializer.Initialize<Person>();
var boisSerializer = new BoisSerializer();
using (var mem = new MemoryStream())
{
boisSerializer.Serialize(personInstance, mem);
return mem.ToArray();
}
Note: Calling BoisSerializer.Initialize
is not required at all, but if the performance of application is important to you, it is better to do it at the begining of your application.
Here is the complete example:
public class Project
{
public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string ProjectUrl { get; set; }
public Version Version { get; set; }
}
class Program
{
static void Main()
{
// Initialize is optional, but recommended for better performance
BoisSerializer.Initialize<Project>();
var projectInstance = new Project()
{
ID = 1,
Name = "Salar.Bois",
ProjectUrl = "https://github.com/salarcode/Bois",
Version = new Version(3, 0, 0, 0),
Description = "Salar.Bois is a compact, fast and powerful binary serializer for .NET Framework."
};
var boisSerializer = new BoisSerializer();
using (var file = new FileStream("output.data", FileMode.Create))
{
boisSerializer.Serialize(projectInstance, file);
}
// All done.
// ...
// if you want to have more compression using LZ4 wrapper
var boisLz4Serializer = new BoisLz4Serializer();
using (var file = new FileStream("output-compressed.data", FileMode.Create))
{
boisLz4Serializer.Pickle(projectInstance, file);
}
}
}
How to deserialize an object:
var boisSerializer = new BoisSerializer();
return boisSerializer.Deserialize<Project>(dataStream);
// and the compressed data
var boisLz4Serializer = new BoisLz4Serializer();
return boisLz4Serializer.Unpickle<Project>(dataStream);
Defining objects
Nothing special is really required. Just these small easy rules.
- Having parameter-less public constructor.
- Collections/Lists should be generic and implement one of ICollection<>, IList<> or IDictionary<>
Compression
The BoisLz4Serializer
class is in a separate package called Salar.Bois.LZ4
. It is provided for anyone looking for more compact serialization. To use it just create a new instance of BoisLz4Serializer
and to serialize and compress the objects call Pickle
and to deserialize and uncompress call Unpickle
.
Please note that BoisLz4Serializer
-for now- is implemented as a wrapper around LZ4.
Bois Format
If you are interested to know how Salar.Bois has gain this amazing compact format check out its Bois format wiki page.
Benchmarks
The benchmarks sourcecode is available. Every elapsed time is calculated for 5000 iteration (v3.0).
Please note that in these tests no configuration required for Bois versus attributes required for Avro, Zero, MsPack and ProtoZBuff. Also Zero required the properties to be virtual.
-Serialization against: ArrayTypes with small data
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 58 | 6 ms | 5 ms | Binary | |
Salar.Bois.LZ4 | 59 | 25 ms | 6 ms | Binary | |
Microsoft.Avro | 87 | 9 ms | 10 ms | Binary | |
MessagePack | 127 | 4 ms | 4 ms | Binary | |
MessagePackLZ4 | 125 | 18 ms | 5 ms | Binary | |
protobuf-net | 92 | 7 ms | 12 ms | Binary | |
BinaryFormatter | 458 | 59 ms | 48 ms | Binary | |
ZeroFormatter | 153 | 3 ms | 1 ms | Binary |
-Serialization against: ArrayTypes with big data
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 1400 | 70 ms | 73 ms | Binary | |
Salar.Bois.LZ4 | 1342 | 117 ms | 75 ms | Binary | |
Microsoft.Avro | 1709 | 89 ms | 119 ms | Binary | |
MessagePack | 1951 | 19 ms | 28 ms | Binary | |
MessagePackLZ4 | 1593 | 57 ms | 41 ms | Binary | |
protobuf-net | 2161 | 58 ms | 79 ms | Binary | |
BinaryFormatter | 2641 | 52 ms | 50 ms | Binary | |
ZeroFormatter | 2336 | 11 ms | 1 ms | Binary |
-Serialization against: PrimitiveTypes with small data
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 74 | 3 ms | 4 ms | Binary | |
Salar.Bois.LZ4 | 75 | 19 ms | 5 ms | Binary | |
Microsoft.Avro | 77 | 4 ms | 3 ms | Binary | |
MessagePack | 161 | 7 ms | 3 ms | Binary | |
MessagePackLZ4 | 173 | 22 ms | 3 ms | Binary | |
protobuf-net | 91 | 6 ms | 7 ms | Binary | |
BinaryFormatter | 671 | 72 ms | 79 ms | Binary | |
ZeroFormatter | 134 | 7 ms | 0 ms | Binary |
-Serialization against: ComplexCollections with small data
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 82 | 14 ms | 23 ms | Binary | |
Salar.Bois.LZ4 | 81 | 30 ms | 24 ms | Binary | |
Microsoft.Avro | - | - | - | Binary | Error |
MessagePack | 171 | 27 ms | 19 ms | Binary | |
MessagePackLZ4 | 153 | 42 ms | 21 ms | Binary | |
protobuf-net | 150 | 17 ms | 34 ms | Binary | |
BinaryFormatter | 10852 | 636 ms | 612 ms | Binary | |
ZeroFormatter | - | - | - | Binary | Not supported |
-Serialization against: ComplexCollections with big data
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 10414 | 356 ms | 411 ms | Binary | |
Salar.Bois.LZ4 | 7628 | 837 ms | 483 ms | Binary | |
Microsoft.Avro | - | - | - | Binary | Error |
MessagePack | 11013 | 796 ms | 301 ms | Binary | |
MessagePackLZ4 | 7636 | 28 ms | 390 ms | Binary | |
protobuf-net | 14865 | 7 ms | 265 ms | Binary | |
BinaryFormatter | 34751 | 961 ms | 488 ms | Binary | |
ZeroFormatter | - | - | - | Binary | Not supported |
-Serialization against: ComplexContainer Collections
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 120 | 9 ms | 11 ms | Binary | |
Salar.Bois.LZ4 | 114 | 27 ms | 12 ms | Binary | |
Microsoft.Avro | - | - | - | Binary | Not supported |
MessagePack | - | - | - | Binary | Not supported |
protobuf-net | 171 | 14 ms | 24 ms | Binary | |
BinaryFormatter | 7396 | 379 ms | 475 ms | Binary | |
ZeroFormatter | - | - | - | Binary | Not supported |
-Serialization against: SpecializedCollections
Serializer | Payload Size (bytes) | Serialization | Deserialization | Format | Note |
---|---|---|---|---|---|
Salar.Bois | 28 | 9 ms | 17 ms | Binary | |
Salar.Bois.LZ4 | 29 | 22 ms | 17 ms | Binary | |
Microsoft.Avro | - | - | - | Binary | Invalid Result |
MessagePack | - | - | - | Binary | Not supported |
MessagePackLZ4 | - | - | - | Binary | Not supported |
protobuf-net | - | - | - | Binary | Not supported |
BinaryFormatter | 2515 | 763 ms | 285 ms | Binary | |
ZeroFormatter | - | - | - | Binary | Not supported |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Salar.Bois:
Package | Downloads |
---|---|
Salar.Bois.LZ4
Salar's Serializer for Binary Object Indexed Serialization, LZ4 wrapper |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.4.0 | 9,082 | 10/22/2023 |
3.2.1 | 18,829 | 1/3/2022 |
3.2.0 | 6,636 | 11/24/2021 |
3.1.0 | 25,047 | 9/30/2019 |
3.0.0.6 | 17,098 | 7/30/2019 |
3.0.0.3 | 974 | 7/29/2019 |
3.0.0-beta2 | 570 | 12/1/2018 |
3.0.0-beta1 | 611 | 9/25/2018 |
2.2.2 | 5,132 | 8/19/2016 |
2.2.1 | 1,687 | 4/23/2016 |
2.2.0 | 1,597 | 12/12/2015 |
2.1.0 | 1,117 | 12/11/2015 |
2.0.0 | 3,938 | 7/6/2015 |
1.8.2 | 1,358 | 1/27/2015 |
1.8.1 | 2,087 | 1/4/2015 |
1.8.0 | 1,550 | 1/3/2015 |
1.7.0 | 1,479 | 5/8/2014 |
1.6.503.157 | 3,589 | 5/3/2013 |
1.5.426.132 | 1,265 | 4/29/2013 |
1.5.414.130 | 1,231 | 4/14/2013 |
1.0.318.72 | 1,248 | 3/18/2013 |
1.0.318.71 | 1,205 | 3/18/2013 |
+ .NET Core 5.0 support added.
+ Generic type serialize/deserialize method added