Wivuu.Sprog
0.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Wivuu.Sprog --version 0.3.0
NuGet\Install-Package Wivuu.Sprog -Version 0.3.0
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="Wivuu.Sprog" Version="0.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Wivuu.Sprog --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Wivuu.Sprog, 0.3.0"
#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 Wivuu.Sprog as a Cake Addin #addin nuget:?package=Wivuu.Sprog&version=0.3.0 // Install Wivuu.Sprog as a Cake Tool #tool nuget:?package=Wivuu.Sprog&version=0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sprog
Sprog (Danish for 'Language') cross-platform string parsing library written for C# 7+ and .NET Core.
Usage
Parsing a simple identifier
Parser TakeIdentifier(string input, out string _id) =>
new Parser(input)
.Skip(IsWhiteSpace)
.Take(IsLetter, out char first)
.Take(IsLetterOrDigit, out string rest)
.Skip(IsWhiteSpace)
.Let(_id = Concat(first, rest));
TakeIdentifier(" abc123 ", out var id);
Assert.AreEqual("abc123", id);
Performance
Preliminary results are promising, with performance nearly 30x faster than Sprache in a naive XML parsing benchmark, using far less memory and GC usage thanks to Sprog
s reliance on the stack rather than heap allocation.
BenchmarkDotNet=v0.13.2, OS=macOS 13.0.1 (22A400) [Darwin 22.1.0]
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 6 logical and 6 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
Identifier
Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
---|---|---|---|---|---|---|---|---|---|
SprogSimple | 85.69 ns | 0.565 ns | 0.501 ns | 1.00 | 0.00 | 0.0063 | - | 40 B | 1.00 |
RegexSimple | 207.36 ns | 1.439 ns | 1.202 ns | 2.42 | 0.02 | 0.0675 | - | 424 B | 10.60 |
RegexSourceGenerator | 198.15 ns | 3.678 ns | 5.505 ns | 2.36 | 0.06 | 0.0675 | - | 424 B | 10.60 |
SpracheSimple | 1,681.40 ns | 25.148 ns | 23.523 ns | 19.64 | 0.28 | 0.9155 | 0.0038 | 5744 B | 143.60 |
XML
Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
---|---|---|---|---|---|---|---|---|---|
SprogXml | 3.721 μs | 0.0340 μs | 0.0284 μs | 1.00 | 0.00 | 0.3738 | - | 2.3 KB | 1.00 |
SpracheXml | 120.923 μs | 0.8570 μs | 0.7597 μs | 32.49 | 0.38 | 51.2695 | 1.7090 | 314.19 KB | 136.33 |
Roadmap
- Improved samples and documentation
- More test coverage
Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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 |
---|---|---|
0.4.0 | 3,093 | 7/1/2023 |
0.3.0 | 372 | 11/13/2022 |
0.2.0 | 612 | 10/13/2019 |
0.1.118 | 544 | 7/3/2019 |
0.1.117.2 | 646 | 7/3/2019 |
0.1.117 | 704 | 12/4/2018 |
0.1.114-beta | 840 | 3/8/2018 |
0.1.111-beta | 798 | 1/13/2018 |
0.1.110-beta | 800 | 1/7/2018 |
0.1.108-beta | 832 | 1/3/2018 |
0.1.106-beta | 795 | 12/27/2017 |
0.1.105-beta | 773 | 12/24/2017 |
0.1.104-beta | 776 | 12/23/2017 |
0.1.99-beta | 874 | 12/23/2017 |