Skip to content

tuyennv216/BinaryContainer

Repository files navigation

BinaryContainer Utilities

Introduction

BinaryContainer is a .NET library providing tools and containers for working with binary serialization. The project is designed to support efficient data processing operations with high extensibility.

Key Features

  • Common usage: Object to binary serialization and deserialization
  • Multiple Data Type Support: Primitive Types, List, Dictionary, Enum, Class
  • A key feature is its support for recursive and circular references
  • Support for Dictionary with class as key

Usage

var bindata = DataConvert.Instance.GetBytes(data)!;
var item = DataConvert.Instance.GetItem<ItemType>(bindata)!;

Performance

  • Get Bytes
Method Mean Error StdDev Median Gen0 Gen1 Allocated
GetBytes_SimpleObject 4,170.7267 ns 80.1711 ns 85.7822 ns 4,195.1401 ns 0.6638 - 5568 B
JsonSerializer_SimpleObject 421.5582 ns 4.4189 ns 4.1334 ns 420.5198 ns 0.0181 - 152 B
GetBytes_ComplexObject 11,612.7607 ns 74.2891 ns 62.0347 ns 11,612.0987 ns 1.8311 0.0305 15320 B
JsonSerializer_ComplexObject 1,223.1679 ns 18.4110 ns 16.3209 ns 1,219.7922 ns 0.0782 - 656 B
GetBytes_SimpleList 236,730.6510 ns 2,974.8255 ns 2,782.6536 ns 235,945.7031 ns 42.4805 9.0332 357016 B
JsonSerializer_SimpleList 37,948.2784 ns 389.1355 ns 344.9585 ns 37,972.5800 ns 1.5259 - 13248 B
GetBytes_ComplexList 539,978.1836 ns 4,666.0164 ns 4,364.5947 ns 540,068.1641 ns 90.8203 5.8594 760936 B
JsonSerializer_ComplexList 53,286.3558 ns 206.0731 ns 172.0804 ns 53,263.6780 ns 1.7700 - 15184 B
GetBytes_Dictionary 53,062.7197 ns 399.4553 ns 333.5633 ns 53,004.6875 ns 9.6436 0.7324 80792 B
JsonSerializer_Dictionary 8,468.5009 ns 166.3877 ns 155.6391 ns 8,492.8757 ns 0.3662 - 3072 B
GetBytes_Null 0.8541 ns 0.0347 ns 0.0324 ns 0.8542 ns - - -
JsonSerializer_Null 87.6080 ns 0.9956 ns 0.8826 ns 87.2731 ns 0.0038 - 32 B
GetBytes_PrimitiveTypes 4,424.4833 ns 66.3744 ns 62.0867 ns 4,429.1931 ns 0.6943 - 5840 B
JsonSerializer_PrimitiveTypes 687.4882 ns 5.8371 ns 5.1745 ns 685.6393 ns 0.0343 - 288 B
GetBytes_LargeString 2,198.1594 ns 43.6303 ns 85.0975 ns 2,161.0840 ns 2.5597 0.0648 21416 B
JsonSerializer_LargeString 2,953.8167 ns 69.7446 ns 196.7159 ns 2,912.7399 ns 0.2441 - 2064 B
GetBytes_ArrayOfPrimitives 25,910.0586 ns 511.7445 ns 765.9552 ns 25,588.6475 ns 8.5144 0.2747 71282 B
JsonSerializer_ArrayOfPrimitives 18,321.9950 ns 341.7940 ns 319.7143 ns 18,285.9497 ns 1.3123 - 11024 B
  • Get Item
Method Mean Error StdDev Median Gen0 Gen1 Allocated
GetItem_SimpleObject 1,557.4551 ns 15.4508 ns 14.4527 ns 1,561.7781 ns 0.4063 0.0019 3408 B
JsonDeserialize_SimpleObject 765.4426 ns 24.4521 ns 72.0977 ns 771.7752 ns 0.0134 - 112 B
GetItem_ComplexObject 4,232.5812 ns 37.5123 ns 31.3245 ns 4,244.2039 ns 1.1063 0.0229 9272 B
JsonDeserialize_ComplexObject 2,293.5132 ns 16.4514 ns 13.7377 ns 2,294.0495 ns 0.2556 - 2168 B
GetItem_SimpleList 100,523.5458 ns 742.7212 ns 729.4515 ns 100,396.8445 ns 26.3672 6.3477 221122 B
JsonDeserialize_SimpleList 74,062.7734 ns 2,142.3395 ns 6,316.7367 ns 70,170.2454 ns 1.4648 - 13064 B
GetItem_ComplexList 208,453.0709 ns 1,525.7217 ns 1,352.5125 ns 208,195.1416 ns 50.5371 18.7988 423579 B
JsonDeserialize_ComplexList 117,353.6229 ns 1,260.2741 ns 1,117.2002 ns 116,919.7388 ns 8.9111 1.4648 75368 B
GetItem_Dictionary 29,444.1517 ns 859.4453 ns 2,534.0941 ns 29,324.7498 ns 6.3171 0.5798 52945 B
JsonDeserialize_Dictionary 18,581.1902 ns 333.4056 ns 710.5145 ns 18,289.5218 ns 0.6409 - 5512 B
GetItem_Null 0.7340 ns 0.0338 ns 0.0316 ns 0.7289 ns - - -
JsonDeserialize_Null 69.8013 ns 0.9822 ns 0.8707 ns 69.8843 ns - - -
GetItem_LargeString 1,038.1523 ns 20.4036 ns 27.2383 ns 1,040.4676 ns 0.8488 0.0153 7112 B
JsonDeserialize_LargeString 2,199.1786 ns 30.6766 ns 31.5026 ns 2,190.7753 ns 0.4578 - 3856 B
GetItem_PrimitiveTypes 1,725.5420 ns 24.8071 ns 21.9908 ns 1,725.4502 ns 0.4578 0.0038 3832 B
JsonDeserialize_PrimitiveTypes 919.4955 ns 7.2862 ns 6.0843 ns 918.6595 ns 0.0210 - 176 B
GetItem_ArrayOfPrimitives 59,450.1997 ns 396.6314 ns 351.6034 ns 59,433.5632 ns 4.4556 0.1831 37737 B
JsonDeserialize_ArrayOfPrimitives 47,677.6363 ns 251.0539 ns 222.5527 ns 47,645.7153 ns 1.4648 - 12448 B
  • Bytes output
Object bin converter bytes > json converter bytes
SimpleObject bindata(*) 104 < jsondata 124
ComplexObject bindata 385 > jsondata(*) 328
SimpleList bindata(*) 8263 < jsondata 12512
ComplexList bindata 19170 > jsondata(*) 14796
Dictionary bindata(*) 1908 < jsondata 2672
Null bindata(*) 0 < jsondata 4
LargeString bindata 2320 > jsondata(*) 2296
Primitive bindata(*) 148 < jsondata 245
PrimitiveArr bindata(*) 4056 < jsondata 10997

License

Project developed under MIT license.

About

Bidirectional Object-to-Binary conversion for data serialization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages