JsonParserPerf 0.1.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 JsonParserPerf --version 0.1.0
NuGet\Install-Package JsonParserPerf -Version 0.1.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="JsonParserPerf" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JsonParserPerf" Version="0.1.0" />
<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.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JsonParserPerf, 0.1.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.
#:package JsonParserPerf@0.1.0
#: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.0
#tool nuget:?package=JsonParserPerf&version=0.1.0
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 about 2x 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 net8.0 and net10.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.
500 customers: our parser vs Google JsonParser
| Parser | Runtime | Mean | Ratio | Allocated |
|---|---|---|---|---|
| Google JsonParser | .NET 10 | 947.5 μs | 1.00 | 781 KB |
| Ours | .NET 10 | 434.1 μs | 0.46 | 206 KB |
| Google JsonParser | .NET 8 | 1,099 μs | 1.00 | 781 KB |
| Ours | .NET 8 | 496.0 μs | 0.45 | 206 KB |
Large model deserialization (200 items): JSON vs binary protobuf
| Parser | Runtime | Mean | Ratio | Allocated |
|---|---|---|---|---|
Binary ParseFrom |
.NET 10 | 1.71 ms | 1.00 | 2.43 MB |
| Ours (JSON) | .NET 10 | 3.68 ms | 2.16 | 2.46 MB |
| Google (JSON) | .NET 10 | 9.35 ms | 5.49 | 6.22 MB |
Binary ParseFrom |
.NET 8 | 2.03 ms | 1.00 | 2.43 MB |
| Ours (JSON) | .NET 8 | 4.50 ms | 2.21 | 3.02 MB |
| Google (JSON) | .NET 8 | 10.63 ms | 5.23 | 6.24 MB |
Summary
- Our parser is 2.2–2.5x faster than Google
JsonParserand allocates 52–74% less memory. - On .NET 10, our JSON parser allocates about the same memory as binary protobuf.
- .NET 10 is about 15% faster than .NET 8 across all parsers.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. 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)
-
net8.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.