JsonParserPerf 0.1.1
dotnet add package JsonParserPerf --version 0.1.1
NuGet\Install-Package JsonParserPerf -Version 0.1.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="JsonParserPerf" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JsonParserPerf" Version="0.1.1" />
<PackageReference Include="JsonParserPerf" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JsonParserPerf --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JsonParserPerf, 0.1.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.
#:package JsonParserPerf@0.1.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JsonParserPerf&version=0.1.1
#tool nuget:?package=JsonParserPerf&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JsonParserPerf
A fast protobuf JSON parser for System.Text.Json. It reads the same JSON that Google's JsonParser reads, but runs 2.5–3x faster and allocates less memory.
Usage
dotnet add package JsonParserPerf
var options = new JsonSerializerOptions().AddProtobuf(registry); // registry is optional
var message = JsonSerializer.Deserialize<MyMessage>(json, options);
Projects
JsonParserPerf: the parser library (targets net10.0; for .NET 8 use version 0.1.0)JsonParserPerf.ProtobufDataModels:.prototest modelsJsonParserPerf.Tests: unit tests and parity tests against Google's parserJsonParserPerf.Benchmarks: BenchmarkDotNet benchmarks
Run
dotnet test
dotnet run -c Release --project JsonParserPerf.Benchmarks -f net10.0 -- --filter '*'
Benchmarks
Intel Core i7-8665U, Arch Linux, performance power profile, BenchmarkDotNet 0.15.8 (1 launch, 3 warmup, 10 iterations).
500 customers: our parser vs Google JsonParser
| Parser | Runtime | Mean | Ratio | Allocated |
|---|---|---|---|---|
| Google JsonParser | .NET 10 | 1,049 μs | 1.00 | 781 KB |
| Ours | .NET 10 | 399.5 μs | 0.38 | 198 KB |
Large model deserialization (200 items): JSON vs binary protobuf
| Parser | Runtime | Mean | Ratio | Allocated |
|---|---|---|---|---|
Binary ParseFrom |
.NET 10 | 1.94 ms | 1.00 | 2.43 MB |
| Ours (JSON) | .NET 10 | 3.35 ms | 1.73 | 2.36 MB |
| Google (JSON) | .NET 10 | 10.36 ms | 5.35 | 6.22 MB |
Summary
- Our parser is 2.6–3.1x faster than Google
JsonParserand allocates 62–75% less memory. - On .NET 10, our JSON parser allocates slightly less memory than binary protobuf.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Google.Protobuf (>= 3.36.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.