BinaryBuffers 3.0.1

dotnet add package BinaryBuffers --version 3.0.1                
NuGet\Install-Package BinaryBuffers -Version 3.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BinaryBuffers" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BinaryBuffers --version 3.0.1                
#r "nuget: BinaryBuffers, 3.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BinaryBuffers as a Cake Addin
#addin nuget:?package=BinaryBuffers&version=3.0.1

// Install BinaryBuffers as a Cake Tool
#tool nuget:?package=BinaryBuffers&version=3.0.1                

BinaryBuffers

logo

NuGet

BinaryBuffers offers a highly performant implementation of BinaryReader and BinaryWriter, working directly on a byte array, thus eliminating the need for an intermediate Stream object.

How to use

BinaryBufferReader and BinaryBufferWriter are the respective names of the reader and writer. Both classes operate on a byte[] as its underlying data buffer.

// Provide a buffer to the reader/writer
var buffer = new byte[100];

// Write to the buffer
var writer = new BinaryBufferWriter(buffer);

writer.Write(2019);
writer.Write(8.11);

// Read from the buffer
var reader = new BinaryBufferReader(buffer);

var year = reader.ReadInt32();
var time = reader.ReadDouble();

Benchmarks

Performance tests were executed using .NET 8 running on a machine with a 16-core CPU.

BinaryBufferReader

Method Mean Error StdDev Ratio
BinaryReader_ReadInt 16.592 ms 0.0296 ms 0.0277 ms baseline
BufferReader_ReadInt 9.752 ms 0.0139 ms 0.0124 ms -41% 0.2%
BinaryReader_ReadDecimal 72.75 ms 0.253 ms 0.211 ms baseline
BufferReader_ReadDecimal 37.22 ms 0.118 ms 0.104 ms -49%
BinaryReader_ReadFloat 9.053 ms 0.0325 ms 0.0304 ms baseline
BufferReader_ReadFloat 6.257 ms 0.0150 ms 0.0133 ms -31% 0.3%

BinaryBufferWriter

Method Mean Error StdDev Ratio
BinaryWriter_WriteInt 58.33 ms 0.066 ms 0.062 ms baseline
BufferWriter_WriteInt 21.13 ms 0.046 ms 0.043 ms -64% 0.2%
BinaryWriter_WriteDecimal 38.592 ms 0.0729 ms 0.0569 ms baseline
BufferWriter_WriteDecimal 8.847 ms 0.0351 ms 0.0328 ms -77%
BinaryWriter_WriteFloat 30.86 ms 0.106 ms 0.100 ms baseline
BufferWriter_WriteFloat 10.14 ms 0.023 ms 0.020 ms -67% 0.3%
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BinaryBuffers:

Package Downloads
LiteCDF

A high performance compound document format (CDF) reader.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 116 6/13/2024
2.0.2 1,036 6/19/2022