-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add benchmarks for RDG #50266
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
Add benchmarks for RDG #50266
Conversation
@@ -0,0 +1,3 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. | |||
// The .NET Foundation licenses this file to you under the MIT license. | |||
global using Xunit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this because the shared RequestDelegateCreationTestBase
has some asserts. I'm just importing Xunit into the context instead of adding if-defs to the shared code to avoid calling Assert
all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Can we add this explanation as a comment to this line 🙂
@@ -6,13 +6,34 @@ | |||
<ServerGarbageCollection>true</ServerGarbageCollection> | |||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||
<RootNamespace>Microsoft.AspNetCore.Http</RootNamespace> | |||
<PreserveCompilationContext>true</PreserveCompilationContext> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to enable this to support passing assembly info to the Roslyn compilation instance at runtime.
Approved for RC2 |
var source = ""; | ||
for (var i = 0; i < EndpointCount; i++) | ||
{ | ||
source += $"""app.MapGet("/route{i}", (int? id) => "Hello World!");"""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the source
creation into:
[GlobalSetup]
public void Setup()
{
// ..
}
so we aren't measuring string creation.
@@ -17,6 +17,7 @@ | |||
|
|||
<ItemGroup> | |||
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Extensions.Tests" /> | |||
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Microbenchmarks" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: which internal types do we need this for? I had assumed that RunGenerator should just work by passing it a source and the generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RequestDelegateCreationTestBase
class that I'm source-sharing between our integration tests and our benchmarks dependencies on some types that are internal to the generator (e.g. the Endpoint
type which represents the info we've derived vai Roslyn about a method invocation that maps to a minimal API).
I could've done work work to factor out the RequestDelegateCreationTestBase class here but I figured there was no harm in doing IVT between our benchmarks and generator.
Also, it'll help in the future if we decide to profile specific parts of the generator implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the explanation. I know other repos like dotnet/runtime try to avoid IVT for these cases and prefer source sharing instead but I think both approaches are fine 😃
Add microbenchmarks for RequestDelegateGenerator