Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize type resolving #1629

Merged

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Oct 2, 2023

  • reuse same HashSet for reservedTypeNames instead re-creating on every cache miss
  • cleanup csprojs
  • let NUKE regenerate GH actions definitions
  • remove build configurations for _build project in solution file (prevents local command line usage)
  • use string interpolation for better optimizations (NET 6+ has optimizations)

The test case has only 3 types and shows the difference quite nicely, real world usage can have hundreds of items, if not thousands.

NJsonSchema.Benchmark.CSharpTypeResolverBenchmark

Diff Method Mean Error Allocated
Old RegisterSchemaDefinitions 1.119 μs 0.0162 μs 1.66 KB
New 645.8 ns (-44%) 5.40 ns 888 B (-48%)

@lahma lahma force-pushed the optimize-DefaultTypeNameGenerator branch from ac78ad1 to 3e2e17b Compare October 2, 2023 06:41
@lahma lahma marked this pull request as ready for review October 2, 2023 06:52
* reuse same HashSet for reservedTypeNames instead re-creating on every cache miss
* cleanup csprojs
* remove build configurations for _build project in solution file
* use string interpolation for better optimizations
@lahma lahma force-pushed the optimize-DefaultTypeNameGenerator branch from 3e2e17b to 0cedbe9 Compare October 2, 2023 06:59
@RicoSuter RicoSuter merged commit d6f0d01 into RicoSuter:master Oct 2, 2023
1 check passed
@RicoSuter
Copy link
Owner

thanks

@lahma lahma deleted the optimize-DefaultTypeNameGenerator branch October 2, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants