ResizableSpanWriter 1.0.1

dotnet add package ResizableSpanWriter --version 1.0.1                
NuGet\Install-Package ResizableSpanWriter -Version 1.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="ResizableSpanWriter" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ResizableSpanWriter --version 1.0.1                
#r "nuget: ResizableSpanWriter, 1.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 ResizableSpanWriter as a Cake Addin
#addin nuget:?package=ResizableSpanWriter&version=1.0.1

// Install ResizableSpanWriter as a Cake Tool
#tool nuget:?package=ResizableSpanWriter&version=1.0.1                

Overview

alternate text is missing from this package README image NuGet version (ResizableSpanWriter)

High-performance writer for creating Span<T> and Memory<T> structures that outperforms MemoryStream, RecyclableMemoryStream and ArrayPoolBufferWriter (MS High Performance Toolkit).

Example Usage

// count of sample integers we'll append the writer
var cnt = 2000;

// instantiate with desired type arguement
var writer = new ResizableSpanWriter<int>();

// normal span for illustrative purposes and checksum below
Span<int> span = new int[cnt];

for (int i = 0; i < cnt; i++)
{
	// write to ResizableSpanWriter
	writer.Write(i);

	// write to Span
	span[i] = i;
}

// read from ResizableSpanWriter.WrittenSpan
Console.WriteLine(writer.WrittenSpan.SequenceEqual(span));	

Benchmarks

Benchmarks performed using BenchmarkDotNet...

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1415 (21H2)
Intel Core i9-10980XE CPU 3.00GHz, 1 CPU, 36 logical and 18 physical cores
.NET SDK=6.0.101
  [Host]     : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
  Job-XTVWKK : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT

|                 Method | TotalCount |      Mean |     Error | Ratio |
|----------------------- |----------- |----------:|----------:|------:|
|           MemoryStream |        100 |  2.452 us | 0.0497 us |  1.00 |
|    ResizableSpanWriter |        100 |  2.497 us | 0.0558 us |  1.02 |
|  ArrayPoolBufferWriter |        100 |  2.888 us | 0.0623 us |  1.19 |
| RecyclableMemoryStream |        100 |  6.735 us | 0.1385 us |  2.79 |
|                        |            |           |           |       |
|    ResizableSpanWriter |      10000 |  5.981 us | 0.1250 us |  0.96 |
|           MemoryStream |      10000 |  6.429 us | 0.3840 us |  1.00 |
|  ArrayPoolBufferWriter |      10000 |  6.890 us | 0.1348 us |  1.10 |
| RecyclableMemoryStream |      10000 | 12.671 us | 0.2534 us |  2.00 |
|                        |            |           |           |       |
|    ResizableSpanWriter |     100000 | 31.933 us | 0.6427 us |  0.90 |
|           MemoryStream |     100000 | 35.572 us | 0.7141 us |  1.00 |
|  ArrayPoolBufferWriter |     100000 | 41.672 us | 0.8295 us |  1.18 |
| RecyclableMemoryStream |     100000 | 60.085 us | 0.6064 us |  1.69 |

Feedback, Suggestions and Contributions

Are all welcome!

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 334 2/14/2023
1.0.0 490 2/14/2023