Repository navigation
Benchmark source-generated deserialization - #175
Merged
Merged
Conversation
SourceGeneratedBenchmarks only covered serialization, so a change to the generated readers could not show up in the benchmarks. Adds a generated-context deserialization of the large document, compared with the YamlDotNet static generator, and a deserialization that goes through a `<<` merge key. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SourceGeneratedBenchmarksnow also covers deserialization through a generated context, including a<<merge key, so a change to the generated readers can show up in the benchmarks.Why
The class only had serialization benchmarks, and the POCO deserialize benchmarks call
YamlSerializer.Deserialize<T>(yaml)rather than a generated reader. A change to the source generator's readers, such as #172 and #174, could not be measured with the existing benchmarks at all.What
SharpYaml_SourceGenerated_DeserializeandYamlDotNet_StaticGenerator_Deserializeread the same large document that the serialize benchmark writes, as a baseline-and-comparison pair in theDeserialize_SourceGeneratedcategory.SharpYaml_SourceGenerated_Deserialize_MergeKeysreads a smallDatabaseConfigurationwhere most members come from a<<mapping, in its own category so its ratio is not mixed with the large document.Results
BenchmarkDotNet default job, 3 runs per figure on one machine (Apple silicon, .NET 10):
SharpYaml_SourceGenerated_DeserializeYamlDotNet_StaticGenerator_DeserializeSharpYaml_SourceGenerated_Deserialize_MergeKeysI used these to check #172 and #174. Over three alternating runs of
mainagainst those changes, time stays within run-to-run noise. A first version of #172 allocated 48 bytes per object read, which this benchmark caught and #172 now fixes.Run
🤖 Generated with Claude Code