{"id":16774646,"url":"https://github.com/salarcode/binarybuffers","last_synced_at":"2025-07-03T02:05:23.670Z","repository":{"id":35088336,"uuid":"204914702","full_name":"salarcode/BinaryBuffers","owner":"salarcode","description":"An implementation of BinaryReader and BinaryWriter which works on binary arrays directly","archived":false,"fork":false,"pushed_at":"2023-07-07T00:07:03.000Z","size":213,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-03T02:02:45.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salarcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-28T11:21:20.000Z","updated_at":"2025-06-20T23:13:43.000Z","dependencies_parsed_at":"2025-02-17T23:32:55.187Z","dependency_job_id":"4ad0e5f0-15f6-44c3-81db-0d7b65236053","html_url":"https://github.com/salarcode/BinaryBuffers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/salarcode/BinaryBuffers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBinaryBuffers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBinaryBuffers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBinaryBuffers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBinaryBuffers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salarcode","download_url":"https://codeload.github.com/salarcode/BinaryBuffers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salarcode%2FBinaryBuffers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263245300,"owners_count":23436512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T06:49:45.597Z","updated_at":"2025-07-03T02:05:23.640Z","avatar_url":"https://github.com/salarcode.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BinaryBuffers\n\n![logo](https://github.com/salarcode/BinaryBuffers/blob/master/img/logo.png)\n\n[![NuGet](https://img.shields.io/nuget/v/Salar.BinaryBuffers.svg)](https://www.nuget.org/packages/Salar.BinaryBuffers)\n\nBinaryBuffers offers a highly performant implementation of `BinaryReader` and `BinaryWriter`, working directly on a `byte` array, thus eliminating the need for an intermediate `Stream` object.\n\n# How to use\n\n`BinaryBufferReader` and `BinaryBufferWriter` are the respective names of the reader and writer. Both classes operate on a `byte[]` as its underlying data buffer.\n\n```csharp\n// Provide a buffer to the reader/writer\nvar buffer = new byte[100];\n\n// Write to the buffer\nvar writer = new BinaryBufferWriter(buffer);\n\nwriter.Write(2022);\nwriter.Write(8.11);\n\n// Read from the buffer\nvar reader = new BinaryBufferReader(buffer);\n\nvar year = reader.ReadInt32();\nvar time = reader.ReadDouble();\n```\n\n## Additional Goodies\nUse `StreamBufferWriter` as a drop in replacement for `BinaryWriter` to gain ~10% improvement in performance.\n\nUse `StreamBufferReader` as a drop in replacement for `BinaryReader`. Note that there is no performance benefit in using `StreamBufferReader`, it just helps widen the use of `IBufferReader`.\n\nUse `ResetBuffer` method in `BinaryBufferReader` and `BinaryBufferWriter` instead of creating a new one and have less allocations!\n\n# Benchmarks\n\nBenchmarks shows up to **92%** improvement in writing and **84%** in reading.\n\n| BinaryBufferReader |     |     |     |     |\n| --- | --- | --- | --- | --- |\n| **Method** | **Mean** | **Error** | **StdDev** | **Ratio** |\n| `BinaryReader_ReadInt` | 42.23 ms | 0.1487 ms | 0.1318 ms | baseline |\n| `BufferReader_ReadInt` |  5.53 ms | 0.0265 ms | 0.0221 ms |     -89% |\n| `BinaryReader_ReadDecimal` | 48.28 ms | 0.2038 ms | 0.1906 ms | baseline |\n| `BufferReader_ReadDecimal` | 34.75 ms | 0.3921 ms | 0.3476 ms |     -28% |\n| `BinaryReader_ReadFloat` | 25.76 ms | 0.1012 ms | 0.0947 ms | baseline |\n| `BufferReader_ReadFloat` |  3.75 ms | 0.0209 ms | 0.0195 ms |     -92% |\n\n| BinaryBufferWriter |     |     |     |     |\n| --- | --- | --- | --- | --- |\n| **Method** | **Mean** | **Error** | **StdDev** | **Ratio** |\n| `BinaryWriter_WriteInt` | 62.71 ms | 0.5090 ms | 0.4761 ms | baseline |\n| `BufferWriter_WriteInt` | 11.05 ms | 0.0307 ms | 0.0240 ms |     -77% |\n| `BinaryWriter_WriteDecimal` | 42.07 ms | 0.1556 ms | 0.1455 ms | baseline |\n| `BufferWriter_WriteDecimal` |  7.79 ms | 0.0191 ms | 0.0169 ms |     -84% |\n| `BinaryWriter_WriteFloat` | 33.38 ms | 0.1869 ms | 0.1561 ms | baseline |\n| `BufferWriter_WriteFloat` |  7.79 ms | 0.0191 ms | 0.0169 ms |     -84% |\n\nPerformance tests were generated using **.NET 7.0.5** on:\n```\nAMD Ryzen 9 5900X, 1 CPU, 24 logical and 12 physical cores\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalarcode%2Fbinarybuffers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalarcode%2Fbinarybuffers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalarcode%2Fbinarybuffers/lists"}