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

Improve performance / allocations of RegisterAs* methods #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bollhals
Copy link

@bollhals bollhals commented May 1, 2021

PR 5 extracted out of #40

Focused on the RegisterAs methods

Main change:

  • NamedInstanceDictionaryRegistration changed to a singleton as it contains no state
  • Avoid calling TryRemove when we're anyway just set it to a new value anyway
  • A bit of cleanup and reordering to simplify what the difference between the different RegisterAs methods are

Performance measurements:

RegisterTypeAsName

Method Mean Error StdDev Min Max Median Ratio Rank Gen 0 Gen 1 Gen 2 Allocated
Current 627.5 ns 1.79 ns 1.58 ns 625.4 ns 630.0 ns 627.6 ns 1.05 2 0.0696 - - 328 B
Master 711.1 ns 2.84 ns 2.52 ns 707.7 ns 715.9 ns 711.1 ns 1.23 2 0.0858 - - 408 B

RegisterTypeAs

Method Mean Error StdDev Min Max Median Ratio RatioSD Rank Gen 0 Gen 1 Gen 2 Allocated
Current 88.83 ns 1.241 ns 1.160 ns 87.36 ns 90.64 ns 88.38 ns 1.23 0.03 2 0.0204 - - 96 B
Master 146.97 ns 1.455 ns 1.361 ns 144.89 ns 148.69 ns 147.37 ns 2.06 0.02 2 0.0322 - - 152 B

RegisterInstance

Method Mean Error StdDev Min Max Median Ratio RatioSD Rank Gen 0 Gen 1 Gen 2 Allocated
Current 126.6 ns 0.88 ns 0.82 ns 125.5 ns 127.9 ns 126.4 ns 1.14 0.01 2 0.0186 - - 88 B
Master 184.4 ns 1.26 ns 1.18 ns 182.8 ns 186.6 ns 184.4 ns 1.66 0.02 2 0.0305 - - 144 B

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.

1 participant