[Java.Interop.Tools.TypeNameMappings] remove Assembly.GetName().Name usage #559
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.
Context: https://github.com/jonathanpeppers/Benchmarks/blob/cc3f2fb1c8f34c30b5b89b2a2b7e327ab7743bb1/Benchmarks/FullyQualifiedName.cs
I found
Assembly.GetName().Nameis somewhat slow compared to usingAssembly.FullNameand aSubstring.It was an order of magnitude faster on .NET framework on Windows:
But still quite faster on Mono on macOS:
*NOTE: macOS is displaying us (microseconds) and Windows ns (nanoseconds)
I suspect the reason is that
AssemblyNamesplits the string parsingthe
Version,PublicKeyToken, etc. We don't need those values insome cases.
JavaNativeTypeManager.GetPackageNameis heavily used during thebuild in
<GenerateJavaStubs/>:AndroidManifest.xmlacwmap.txtand other typemapsIt is also used at runtime by the Android designer.
After making the change, I could see a small improvement when building
the Xamarin.Forms integration project:
This seems like it will save ~25ms on builds when
<GenerateJavaStubs/>runs.I have seen
<GenerateJavaStubs/>take over a second with some largerprojects, so it is probably worth making this change.