ReflectionIT.HighPerformance
1.0.1
Prefix Reserved
dotnet add package ReflectionIT.HighPerformance --version 1.0.1
NuGet\Install-Package ReflectionIT.HighPerformance -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="ReflectionIT.HighPerformance" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ReflectionIT.HighPerformance --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ReflectionIT.HighPerformance, 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 ReflectionIT.HighPerformance as a Cake Addin #addin nuget:?package=ReflectionIT.HighPerformance&version=1.0.1 // Install ReflectionIT.HighPerformance as a Cake Tool #tool nuget:?package=ReflectionIT.HighPerformance&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ReflectionIT.HighPerformance
A collection of helpers for working in high-performance scenarios.
It includes APIs such as Uf8StringPool
and StringPool
types.
It utilizes the new performance improvements of .NET 9 like AlternateLookup.
Usage examples
Utf8StringPool
using ReflectionIT.HighPerformance.Buffers;
ReadOnlySpan<byte> text = "abc,def,xyz,abc,def,xyz,abc,def,xyz"u8;
foreach (Range range in text.Split((byte)',')) {
ReadOnlySpan<byte> bytes = text[range];
string word = Utf8StringPool.Shared.GetOrAdd(bytes);
Console.WriteLine(word);
}
Console.WriteLine(Utf8StringPool.Shared.Count); // 3
StringPool
Case sensitive StringPool
using ReflectionIT.HighPerformance.Buffers;
ReadOnlySpan<char> text = "abc,def,xyz,abc,def,xyz,abc,def,xyz";
foreach (Range range in text.Split(',')) {
ReadOnlySpan<char> chars = text[range];
string word = StringPool.Shared.GetOrAdd(chars);
Console.WriteLine(word);
}
Console.WriteLine(StringPool.Shared.Count); // 3
Case insensitive StringPool with an initial capacity of 20
using ReflectionIT.HighPerformance.Buffers;
ReadOnlySpan<char> text = "abc,def,xyz,ABC,DEF,XYZ,Abc,Def,Xyz";
StringPool pool = new StringPool(capacity: 20, StringComparer.OrdinalIgnoreCase);
foreach (Range range in text.Split(',')) {
ReadOnlySpan<char> chars = text[range];
string word = pool.GetOrAdd(chars);
Console.WriteLine(word);
}
Console.WriteLine(pool.Count); // 3
Using string interpolation
using ReflectionIT.HighPerformance.Buffers;
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 10; j++) {
string s = StringPool.Shared.GetOrAdd($"Hello World {j}");
}
}
Console.WriteLine(StringPool.Shared.Count); // 10
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.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.
Null checking added and improved README file